What does it mean that the message “internal / external status mismatch is fixed” on MediaPlayer?

I work with MediaPlayer and often set the state of the player, such as:

if(mp.isPlaying()) { mp.pause(); animationPausedMusic(); } private void animationPausedMusic() { // Changing button image to play button btn_play.setBackgroundResource(R.drawable.play); ... // more code } 

But sometimes logcat gives me a message:

"fixed internal / external state mismatch"

And then the play and pause function no longer works.

what does this message mean? And how can I solve it?

+3
android android-mediaplayer
source share
3 answers

After going through the Android built-in environment for the media player, I found that in the source mediaplayer.cpp file inside the bool MediaPlayer::isPlaying() function bool MediaPlayer::isPlaying() developer currentState if the currentState media player is in the STARTED state, but the media player does not play any media, so it tries change state to PAUSED so that state consistency is maintained for API users. (and here he prints the message "ALOGE (" internal / external status mismatch fixed ");)

Now, if you look at the state diagram of the media player below:

enter image description here

You noticed that this can happen when MediaPlayer moves to the “START” state after starting the call (), and at this time, for some unclear reason, the playback has not started yet, and you run the method MediaPlayer.isPlaying() call, The Framework see this as a state inconsistency and become PAUSED, and therefore you cannot see anything else.

However, if someone has a better understanding, share your thoughts!

+5
source share

Recently, I came across this, and, like some other questions, this error (marked by an outdated trick) https://code.google.com/p/android/issues/detail?id=9732

I found that this error occurs when playing a MIDI file, but only occasionally. This happens when mp.isPlaying () is called quickly after mp.start ()

If you fail to call mp.isPlaying () for a short time, an error does not occur. In my case, a tenth of a second or so made the difference between getting the error or not. This is inconvenient, but it works.

eg.

 //setting a new track mp.setDataSource(path); mp.prepare(); mp.start(); //calling mp.isPlaying() here or shortly after starts the problem //since we know it playing, we can store that state, or call updateUiPlaying(); //eg instead of updateUi(); //or just call some code here that takes more time first updateScaledImages(); //something that might take time Log.v(TAG, "mp.isPlaying = " + mp.isPlaying()); //now isPlaying() shouldn't cause that error 

In addition, I put a check when I stop later.

 mp.pause() if(mp.isPlaying()){ //shouldn't be playing, must be in error mp.stop(); mp.release(); mp = new MediaPlayer(); //any other initialization here } 

Although the problem does not occur if there is a wait before calling isPlaying ()

+1
source share

There are apparently several reasons for this post. The following solution worked for me. It may or may not work for you. I called the MediaPlayer.reset () method right after instantiating the MediaPlayer object:

  MediaPlayer mp = new MediaPlayer(); mp.reset(); 
-one
source share

All Articles