2012-02-01 74 views
1

我無法找到解決此問題的解決方案。 我只需要播放一個音頻文件並獲取該文件的持續時間。有時它工作正常,但它顯示錯誤:android:mediaplayer error(1,-17)

下面是我的logcat:

請幫我stucked。

02-01 12:30:40.287: E/MediaPlayer(256): error (1, -17) 
02-01 12:30:41.896: D/MediaPlayer(256): create failed: 
02-01 12:30:41.896: D/MediaPlayer(256): java.io.IOException: Prepare failed.: status=0x1 
02-01 12:30:41.896: D/MediaPlayer(256): at android.media.MediaPlayer.prepare(Native Method) 
02-01 12:30:41.896: D/MediaPlayer(256): at android.media.MediaPlayer.create(MediaPlayer.java:644) 
02-01 12:30:41.896: D/MediaPlayer(256):  at PointOf1761.onClick(PointOf1761.java:953) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.View.performClick(View.java:2364) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.View.onTouchEvent(View.java:4179) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.View.dispatchTouchEvent(View.java:3709) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
02-01 12:30:41.896: D/MediaPlayer(256):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 
02-01 12:30:41.896: D/MediaPlayer(256):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 
02-01 12:30:41.896: D/MediaPlayer(256):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.os.Handler.dispatchMessage(Handler.java:99) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.os.Looper.loop(Looper.java:123) 
02-01 12:30:41.896: D/MediaPlayer(256):  at android.app.ActivityThread.main(ActivityThread.java:4363) 
02-01 12:30:41.896: D/MediaPlayer(256):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-01 12:30:41.896: D/MediaPlayer(256):  at java.lang.reflect.Method.invoke(Method.java:521) 
02-01 12:30:41.896: D/MediaPlayer(256):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
02-01 12:30:41.896: D/MediaPlayer(256):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
02-01 12:30:41.896: D/MediaPlayer(256):  at dalvik.system.NativeStart.main(Native Method) 

it says in line 953 

i have this in 953 

953 female = MediaPlayer.create(this, femaleNum[i]); 
954   handler.postDelayed(new Runnable() { 
955    
956    @Override 
957    public void run() { 
958     female.start(); 
959     
960    } 
961   },1000); 
+0

任何解決方案? PLZ幫助 – Donald 2012-02-01 07:37:09

回答

2

請確保您沒有太多同時活動的MediaPlayer對象。請參閱this以供參考。

+0

謝謝你,我有3個媒體播放器在我的代碼,所以我只需要使用一個? – Donald 2012-02-01 08:43:28

+0

真的不知道你想在這裏實現什麼,但是,你肯定可以停止並重新使用MediaPlayer。 – youri 2012-02-01 09:07:42

+0

我在那裏有三個媒體播放器用於錄製和播放。當我點擊播放時播放錄製的聲音,但在此之前我正在播放音頻。爲此,我使用了getDuration();獲得持續時間,然後播放錄製的語音。這就是我想達到它的工作正常,但有時它顯示這個錯誤與空指針異常 – Donald 2012-02-01 09:11:14

相關問題