这意味着消息"内部/外部状态不匹配校正的QUOT;在MediaPlayer的?不匹配、状态、消息、这意味着

由网友(越努力,越幸运)分享简介:我用MediaPlayer的工作,并设置了播放器的状态往往喜欢编程,例如:I work with a MediaPlayer and set the state of the player often programmatically like for example:if(mp.isPlaying()) {mp.p...

我用MediaPlayer的工作,并设置了播放器的状态往往喜欢编程,例如:

I work with a MediaPlayer and set the state of the player often programmatically like for example:

 if(mp.isPlaying()) {
    mp.pause();
    animationPausedMusic();

  }

private void animationPausedMusic() {

  // Changing button image to play button
    btn_play.setBackgroundResource(R.drawable.play);

  ... // more code
}

但有时的logcat给我的留言:

But sometimes the logcat gives me the message:

内部/外部状态不匹配纠正的

"internal/external state mismatch corrected"

然后播放和暂停功能无法正常工作了。

And then the play and pause function is not working anymore.

这是什么消息呢?我怎么能解决呢?

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

推荐答案

在经历了媒体播放器的Andr​​oid的原生框架后,我发现,在源文件中的里面的功能mediaplayer.cpp 布尔的MediaPlayer :: IsPlaying模块()开发人员正在检查是否 currentState的是入门状态,但媒体播放器是不是在玩任何媒体,因此它试图将状态更改为 PAUSED 状态,这样的状态的一致性,应保持API的用户(这里是哪里,他正在打印消息ALOGE(内部/外部状态不匹配纠正);)。

After going through the android's native framework for media player I found that in source file mediaplayer.cpp inside function bool MediaPlayer::isPlaying() The developer is checking if the currentState of media player is in STARTED state and yet the media player is not playing any media, so it tries to change the state to PAUSED state so that the state consistency should be maintained for API users.(and here is where he is printing the message "ALOGE("internal/external state mismatch corrected");")

现在如果你去通过下面的媒体播放器状态图:

Now If you go through the media player state diagram below:

您会注意到,这可能发生在的MediaPlayer 移动到已启动状态后,调用start(),并在这个时候对一些模糊的原因还没有开始播放,你火了 MediaPlayer.isPlaying()方法调用,该框架将此视为状态不一致,移动到「已暂停状态,这就是为什么你看不到任何东西打进一步提高。

You would notice that this may happen when the MediaPlayer moved to 'STARTED' state after a call to start() and at this time for some obscure reason has not yet started the playback and you fire a MediaPlayer.isPlaying() method call , The Framework treat this as state inconsistency and moves to 'PAUSED' state and that's why you cannot see anything playing further.

不过,如果有人有一些更好的理解,请您分享您的想法!

However, if someone has some better understanding please share your thoughts!