Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaPlayer error: pause called in state 64

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?

like image 559
erdomester Avatar asked Sep 20 '12 20:09

erdomester


1 Answers

I used pause and seekto method to reset the player.

player.pause();
player.seekTo(0);
like image 88
Goran Horia Mihail Avatar answered Sep 17 '22 07:09

Goran Horia Mihail