Reputation: 990
I have a group a mp3 into an array and my app plays them properly. However when the user quits that activity the activity stops but the mp3s keep being played.
Here is the code: Initially I play the mp3 files in an array:
MediaPlayer mPlay = MediaPlayer.create(this, Audios[posicion]);
mPlay.start();
When the user clicks on a certain button the activity ends but the MediaPlayer doesnt stop:
bFinalizar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPlay.stop();
posicion=0;
Listening2.this.finish();
}
});
Upvotes: 0
Views: 85
Reputation: 1479
Try this snippet
try {
mPlayer.stop();
mPlayer.release();
} catch(Exception ex) {
ex.printStackTrace()
}
Upvotes: 1
Reputation: 1860
Try calling mPlay.stop()
in onFinish()
or onDestroy()
of your activity.
Upvotes: 0