我在 LogCat 中收到此错误。
相同的网络应用程序代码在iOS上运行,但是我在Android上收到此错误
Attempt to call getDuration without a valid mediaplayer
谢谢。
添加一个
变量mIsPreparedForPlayback
并将其设置为ready:
mMediaPlayer.setOnPreparedListener(this);
//...
public void onPrepared(final MediaPlayer player) {
mIsPreparedForPlayback = true;
}
然后,您在尝试获取它之前检查一下。