I am using a MediaPlayer
in my Activity
.
When I hit the back button, I get this error:
09-20 19:44:16.540: E/MediaPlayer(1822): pause called in state 64
09-20 19:44:16.540: E/MediaPlayer(1822): error (-38, 0)
Code
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
if (mp!= null && mp.isPlaying()) {
mp.stop();
}
Intent intentstart = new Intent(X.this, Y.class);
intentstart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intentstart);
}
return super.onKeyDown(keyCode, event);
}
If I use mp.pause()
, it's working fine. Why?
I used pause and seekto method to reset the player.
player.pause();
player.seekTo(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With