android:mediaplayer error(1, -17)

2019-01-29 04:35发布

问题:

I am unable to find the solution to this problem. I just have to play an audio file and get the duration of that file. Sometimes it works fine but it shows error:

Below is my logcat:

Please help I am 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);

回答1:

Please make sure you don't have too many MediaPlayer objects active at once. See this for reference.