它是4.4.2和4.4.4中MediaPlayer中的错误

时间:2017-12-01 04:48:30

标签: android android-mediaplayer

我试图播放mp3声音,有时候像计数一样。当我在6.0.1中使用此代码时它可以工作,但在4.4.2和4.4.4中,应用程序崩溃了,不知道为什么? 有什么方法可以解决它,还是有任何声音库可以播放mp3。

注意:我试过Vitamio播放声音,但它有一个错误。

   media = MediaPlayer.create(this, com.alkhulaqi.abdalrhman.htkxhtk.R.raw.sound_count);

    media.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {

                new Thread(new Runnable() {
                    public void run() {
                        for (int i = 0; i < 10; i++) {

                            for (int j = 0; j <= 5; j++) {
                                media.start();
                                try {
                                    Thread.sleep(50);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                }).start();

        }
    });

更新 这是Logcat

    12-01 14:30:32.315 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/View: Touch down dispatch to com.alkhulaqi.abdalrhman.htkxhtk.TextViewStyle{425ec3c0 V.ED..C. ......I. 0,11-232,55 #7f0e01c4 app:id/player_vs_device}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=161.9512, y[0]=27.956726, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2426605, downTime=2426605, deviceId=3, source=0x1002 }
12-01 14:30:32.328 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/GraphicBuffer: create handle(0x54c9c8e8) (w:384, h:380, f:1)
12-01 14:30:32.432 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/View: Touch up dispatch to com.alkhulaqi.abdalrhman.htkxhtk.TextViewStyle{425ec3c0 V.ED..C. ...P.... 0,11-232,55 #7f0e01c4 app:id/player_vs_device}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=161.9512, y[0]=27.956726, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2426718, downTime=2426605, deviceId=3, source=0x1002 }
12-01 14:30:32.450 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk V/Provider/Settings: get setting for user 0 by user 0 so skipping cache
12-01 14:30:32.450 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk V/Provider/Settings:  from settings cache , name = sound_effects_enabled , value = 0
12-01 14:30:32.502 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: Don't notify duration to com.alkhulaqi.abdalrhman.htkxhtk!
12-01 14:30:32.547 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/GraphicBuffer: create handle(0x54c8b810) (w:384, h:380, f:1)
12-01 14:30:32.550 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/OpenGLRenderer: Flushing caches (mode 0)
12-01 14:30:32.551 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/GraphicBuffer: close handle(0x54ca1a80) (w:384 h:380 f:1)
12-01 14:30:32.552 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/GraphicBuffer: close handle(0x54c9c8e8) (w:384 h:380 f:1)
12-01 14:30:32.552 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/GraphicBuffer: close handle(0x54c8b810) (w:384 h:380 f:1)
12-01 14:30:32.579 15197-15535/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=11: interp stack at 0x54cab000
12-01 14:30:32.579 15197-15535/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=11: adding to list (attached)
12-01 14:30:32.579 15197-15535/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=11: attached from native, name=Binder_3
12-01 14:30:32.641 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(5, 0, 0)
12-01 14:30:32.641 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(1, 0, 0)
12-01 14:30:32.642 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk E/MediaPlayer: Should have subtitle controller already set
12-01 14:30:32.642 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(6, 0, 0)
12-01 14:30:32.658 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk V/InputMethodManager: onWindowFocus: null softInputMode=32 first=false flags=#1810580
12-01 14:30:32.669 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk V/InputMethodManager: START INPUT: com.android.internal.policy.impl.PhoneWindow$DecorView{425fc3f8 V.E..... R......D 0,0-600,973} ic=null tba=android.view.inputmethod.EditorInfo@41e13c88 controlFlags=#100
12-01 14:30:33.010 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: Don't notify duration to com.alkhulaqi.abdalrhman.htkxhtk!
12-01 14:30:33.047 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{425f9010 token=android.os.BinderProxy@425f86e0 {com.alkhulaqi.abdalrhman.htkxhtk/com.alkhulaqi.abdalrhman.htkxhtk.MainActivity}}
12-01 14:30:33.066 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/ActivityThread: ACT-PAUSE_ACTIVITY handled : 1 / android.os.BinderProxy@425f86e0
12-01 14:30:33.070 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/Choreographer: Skipped 32 frames!  The application may be doing too much work on its main thread.
12-01 14:30:33.105 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(2, 0, 0)
12-01 14:30:33.108 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(7, 0, 0)
12-01 14:30:33.108 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(5, 0, 0)
12-01 14:30:33.108 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(1, 0, 0)
12-01 14:30:33.109 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk E/MediaPlayer: Should have subtitle controller already set
12-01 14:30:33.109 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: handleMessage msg:(6, 0, 0)
12-01 14:30:33.128 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/dalvikvm: Could not find method com.alkhulaqi.abdalrhman.htkxhtk.StageActivity.finishAfterTransition, referenced from method com.alkhulaqi.abdalrhman.htkxhtk.StageActivity.onBackPressed
12-01 14:30:33.128 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: VFY: unable to resolve virtual method 21941: Lcom/alkhulaqi/abdalrhman/htkxhtk/StageActivity;.finishAfterTransition ()V
12-01 14:30:33.128 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
12-01 14:30:33.151 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk V/ActivityThread: ActivityRecord{41e16568 token=android.os.BinderProxy@41e15c38 {com.alkhulaqi.abdalrhman.htkxhtk/com.alkhulaqi.abdalrhman.htkxhtk.StageActivity}}: app=android.app.Application@41cec608, appName=com.alkhulaqi.abdalrhman.htkxhtk, pkg=com.alkhulaqi.abdalrhman.htkxhtk, comp={com.alkhulaqi.abdalrhman.htkxhtk/com.alkhulaqi.abdalrhman.htkxhtk.StageActivity}, dir=/data/app/com.alkhulaqi.abdalrhman.htkxhtk-2.apk
12-01 14:30:33.161 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
12-01 14:30:33.161 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
12-01 14:30:33.162 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: VFY: unable to resolve interface method 20178: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
12-01 14:30:33.162 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
12-01 14:30:33.162 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
12-01 14:30:33.162 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: VFY: unable to resolve interface method 20182: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
12-01 14:30:33.162 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
12-01 14:30:33.203 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/skia: jpeg_decoder mode 1, config 6, w 247, h 400, sample 1, bsLength 25be!!
12-01 14:30:33.208 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/skia: jpeg_decoder finish successfully, L:1881!!!
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1: SuspendAll starting
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=11 status=7 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=10 status=7 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=9 status=7 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=8 status=2 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=7 status=4 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=6 status=4 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=5 status=8 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=4 status=8 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=3 status=8 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1:   threadid=2 status=8 sc=1 dc=0
12-01 14:30:33.210 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1: SuspendAll complete : 1
12-01 14:30:33.254 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1: ResumeAll starting
12-01 14:30:33.254 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1: ResumeAll waking others
12-01 14:30:33.254 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1: ResumeAll complete
12-01 14:30:33.255 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: GC_FOR_ALLOC freed 974K (21314), 25% free 11259K/14960K, paused 44ms, total 45ms
12-01 14:30:33.268 15197-15207/com.alkhulaqi.abdalrhman.htkxhtk W/MediaPlayer-JNI: MediaPlayer finalized without being released
12-01 14:30:33.282 15197-15207/com.alkhulaqi.abdalrhman.htkxhtk W/MediaPlayer-JNI: MediaPlayer finalized without being released
12-01 14:30:33.349 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
12-01 14:30:33.350 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: VFY: unable to resolve virtual method 661: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
12-01 14:30:33.350 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-01 14:30:33.351 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
12-01 14:30:33.351 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: VFY: unable to resolve virtual method 683: Landroid/content/res/TypedArray;.getType (I)I
12-01 14:30:33.352 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-01 14:30:33.453 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk E/MediaPlayer: Unable to create media player
12-01 14:30:33.474 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/MediaPlayer: create failed:
                                                                               java.io.IOException: setDataSourceFD failed.: status=0x80000000
                                                                                   at android.media.MediaPlayer._setDataSource(Native Method)
                                                                                   at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1035)
                                                                                   at android.media.MediaPlayer.create(MediaPlayer.java:855)
                                                                                   at com.alkhulaqi.abdalrhman.htkxhtk.StageActivity.onCreate(StageActivity.java:93)
                                                                                   at android.app.Activity.performCreate(Activity.java:5264)
                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                                   at android.os.Looper.loop(Looper.java:193)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                   at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
                                                                                   at dalvik.system.NativeStart.main(Native Method)
12-01 14:30:33.478 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/AndroidRuntime: Shutting down VM
12-01 14:30:33.478 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk D/dalvikvm: threadid=1: detach (group=0x41860ce0)
12-01 14:30:33.478 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41860ce0)
12-01 14:30:33.478 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: threadid=1: uncaught exception occurred
12-01 14:30:33.480 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alkhulaqi.abdalrhman.htkxhtk/com.alkhulaqi.abdalrhman.htkxhtk.StageActivity}: java.lang.NullPointerException
12-01 14:30:33.481 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.ActivityThread.access$800(ActivityThread.java:151)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:110)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.os.Looper.loop(Looper.java:193)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5299)
12-01 14:30:33.482 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
12-01 14:30:33.483 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
12-01 14:30:33.483 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
12-01 14:30:33.483 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
12-01 14:30:33.484 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at dalvik.system.NativeStart.main(Native Method)
12-01 14:30:33.485 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err: Caused by: java.lang.NullPointerException
12-01 14:30:33.489 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at com.alkhulaqi.abdalrhman.htkxhtk.StageActivity.onCreate(StageActivity.java:94)
12-01 14:30:33.490 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.Activity.performCreate(Activity.java:5264)
12-01 14:30:33.490 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
12-01 14:30:33.490 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
12-01 14:30:33.490 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/System.err:   ... 11 more
12-01 14:30:33.490 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk W/dalvikvm: threadid=1: calling UncaughtExceptionHandler
12-01 14:30:33.494 15197-15197/com.alkhulaqi.abdalrhman.htkxhtk E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  Process: com.alkhulaqi.abdalrhman.htkxhtk, PID: 15197
                                                                                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alkhulaqi.abdalrhman.htkxhtk/com.alkhulaqi.abdalrhman.htkxhtk.StageActivity}: java.lang.NullPointerException
                                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
                                                                                      at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                                      at android.os.Looper.loop(Looper.java:193)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                                                      at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                      at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
                                                                                      at dalvik.system.NativeStart.main(Native Method)
                                                                                   Caused by: java.lang.NullPointerException
                                                                                      at com.alkhulaqi.abdalrhman.htkxhtk.StageActivity.onCreate(StageActivity.java:94)
                                                                                      at android.app.Activity.performCreate(Activity.java:5264)
                                                                                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
                                                                                      at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                      at android.os.Looper.loop(Looper.java:193) 
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                                                      at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                      at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) 
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
                                                                                      at dalvik.system.NativeStart.main(Native Method) 

2 个答案:

答案 0 :(得分:1)

您获得的例外是java.io.IOException: setDataSourceFD failed.: status=0x80000000

如果文件已损坏,通常会出现此异常,如果获得相同的异常,请检查其他一些文件。

同时查看这些

&gt; MediaPlayer setDataSource failed with status=0x80000000 for Ringtone set by filepath on 2.3.4

&gt; MediaPlayer.setDataSource causes IOException for valid file

答案 1 :(得分:0)

播放媒体(mp3)使用以下代码。它在每个android api级别都受支持。

MediaPlayer mp = MediaPlayer.create(this, R.raw.sound_count); 


                try
                {
                    if (mediaPlayer.isPlaying()) {
                        if (mediaPlayer != null) {
                            mediaPlayer.pause();
                            position = mediaPlayer.getCurrentPosition();
                        }
                    } else {
                        if (mediaPlayer != null) {
                            mediaPlayer.reset(); // This is for when you need to make null mediaplayer.
                            mediaPlayer.setDataSource(audioPath);  //This is for when you play audio from your phone memory.
                            mediaPlayer.prepare();
                            mediaPlayer.start();

                        }
                    }
                }
                catch(Exception ex)
                {
                    ex.printStackTrace();
                }

如果您有查询或错误,请告诉我。 谢谢。