Android + Phonegap:尝试在没有有效媒体播放器的情况下调用getDuration



我在 LogCat 中收到此错误。

相同的网络应用程序代码在iOS上运行,但是我在Android上收到此错误

Attempt to call getDuration without a valid mediaplayer 

谢谢。

添加一个

变量mIsPreparedForPlayback并将其设置为ready:

mMediaPlayer.setOnPreparedListener(this);
//...
public void onPrepared(final MediaPlayer player) {
    mIsPreparedForPlayback = true;
}

然后,您在尝试获取它之前检查一下。

最新更新