2016-07-07 168 views
-2

我正在實施一個android媒體播放器。它只播放很少次,然後停止播放。它給出的錯誤是:E/MediaPlayer: Error (1,-19)。我嘗試過使用mp.release(),但它提供了另一個這樣的錯誤。我該如何解決這個問題?Android媒體播放器:未知問題

07-07 14:37:11.160 20825-20825/com.example.dmacs.myapplication E/AndroidRuntime: FATAL EXCEPTION: main 
    Process: com.example.dmacs.myapplication, PID: 20825 
    java.lang.IllegalStateException 
    at android.media.MediaPlayer._stop(Native Method) 
    at android.media.MediaPlayer.stop(MediaPlayer.java:1200) 
    at com.example.dmacs.myapplication.second_main$1.onClick(second_main.java:184) 
    at android.view.View.performClick(View.java:4780) 
    at android.view.View$PerformClick.run(View.java:19866) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5254) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
07-07 14:38:17.162 21540-21540/com.example.dmacs.myapplication E/MediaPlayer: Should have subtitle controller already set 
+4

發佈您的代碼這裏 ?? – Ironman

回答

1

嘗試這種方式,這裏有兩個是媒體播放器項目,你必須先檢查其播放與否,如果打然後復位,然後重新創建它,並開始

if (two.isPlaying()) { 
      two.reset(); 
      two = MediaPlayer.create(getApplicationContext(), R.raw.two); 
     } 

     two.start();