Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaPlayer gets cleaned up after every completion (Android) #11

Closed
felschr opened this issue Mar 26, 2018 · 3 comments
Closed

MediaPlayer gets cleaned up after every completion (Android) #11

felschr opened this issue Mar 26, 2018 · 3 comments

Comments

@felschr
Copy link

felschr commented Mar 26, 2018

In the callback of the completion event of the Android MediaPlayer the MediaPlayer instance is being removed from the mediaPlayers hashmap:
https://github.com/luanpotter/audioplayer/blob/f67a3a219c6dd3eed9dc820dbfe95ff6ba24cce0/android/src/main/java/bz/rxla/audioplayer/AudioplayerPlugin.java#L79-L84

Is there any reason for this?

It seems that if play is called again that a new instance will be created. But why not reuse it?

@felschr felschr changed the title cannot reuse audioplayer after completion (Android) MediaPlayer gets cleaned up after every completion (Android) Mar 26, 2018
@luanpotter
Copy link
Member

It seems that this behavior was introduced on #7 by @the4thfloor as part of an awesome refactoring related to UI blocking; I wonder if there is a reason for that, or if it was just a slip. What do you guys think? If it is the case, simply removing this line 84 will be better? If so, I'd be glad to merge a PR.

Thanks for your contributions and sorry for the delay!

@ralph-bergmann
Copy link
Contributor

You have to remove line 83 too because after release() the media player is no longer available.
But please note: You need to find another way to release the media player

@luanpotter
Copy link
Member

The way this is handled was fixed in 0.7.0. More details on readme, but basically the players are released by default when finished or stopped, unless you change the release mode. Released players are always recreated when requested (so the lifecycle of the android MediaPlayer is transparent to the user).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants