Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 LogCat 中收到此错误。
相同的网络应用程序代码在 iOS 上运行,但我在 Android 上收到此错误
Attempt to call getDuration without a valid mediaplayer
谢谢你。
添加一个变量mIsPreparedForPlayback并将其设置为准备好的:
mIsPreparedForPlayback
mMediaPlayer.setOnPreparedListener(this); //... public void onPrepared(final MediaPlayer player) { mIsPreparedForPlayback = true; }
然后你在尝试得到它之前检查它。