我有两个正在更新媒体播放器和搜索栏的AsyncTask。第一个是调用runOnUIThread。当我调用第二个asynctask来更新mediaplayer时,我得到了IllegalStateException。日志如下。我该如何解决这个问题?
07-02 08:15:13.786 18990-18990/horatiothomas.com.spotify E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:976)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:929)
at horatiothomas.com.spotify.ui.TrackPlayerActivityFragment$SwitchTrackPlayerTask$1.success(TrackPlayerActivityFragment.java:260)
at horatiothomas.com.spotify.ui.TrackPlayerActivityFragment$SwitchTrackPlayerTask$1.success(TrackPlayerActivityFragment.java:238)
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:2)
我需要在我的媒体播放器上调用reset()。
答案 1 :(得分:0)
媒体播放器还没有准备好,或者它仍然是空的,你正试图玩它。