I have some background music playing on my android app, which works as expected. When another activity overtakes the screen, the music pause as expected and resumes once the jME app is in the foreground again. However, if I use the “back” button, which invokes the “stop” method, the background music continues to loop indefinitely. I trace the cause of this back to AndroidHarness where audio is explicitly paused in the onPause() method but nothing is done in the onStop method.
I tried putting the audio stop code inside the onStop() method but that doesn’t work since we cannot count on onStop() to be called according to the official Android doc. I decided to put an explicit stop to the audio by overriding the stop() method of Application (which is called by the “Do you want to exit” dialog box).
What I’m wondering is if this is the right thing to do? Or is there a different way to handle this situation? Basically, we need to find a way to stop looping music from playing on exit.