Reputation: 10929
I have a fragment that calls a class which has a mediaplayer in it. On minimizing or closing the app, the mediaplayer continues to play. If the mediaplayer is part of the activity then I can use onPause and onStop methods in which I can say mediaplayer.release() to stop it. Is there something similar that I can do in a class to stop the mediaplayer?
Upvotes: 2
Views: 438
Reputation: 9805
If you declare the media player as static
in the class, you can start and stop it in your activities onPause
and onResume
methods by referencing it through the class name.
Upvotes: 1