Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用java.io.IOException创建媒体播放器:setDataSourceFD失败:2.3.3 android tablet中的状态=0x8000000_Java_Android - Fatal编程技术网

无法使用java.io.IOException创建媒体播放器:setDataSourceFD失败:2.3.3 android tablet中的状态=0x8000000

无法使用java.io.IOException创建媒体播放器:setDataSourceFD失败:2.3.3 android tablet中的状态=0x8000000,java,android,Java,Android,您好,我是android新手,请帮助我,我的音频文件格式是正确的。mp4和mp3,然后有时它也会给我这个错误java.io.IOException:setDataSourceFD failed.:status=0x8000000或有时java.lang.NullPointerException 看到我的日志了吗 我不明白有时它的工作完美,有时不完美。我用过这个 方法以静态方式进行活动 java.io.IOException:setDataSourceFD失败-音乐文件似乎是以一种奇怪的格式编码的

您好,我是android新手,请帮助我,我的音频文件格式是正确的。mp4和mp3,然后有时它也会给我这个错误java.io.IOException:setDataSourceFD failed.:status=0x8000000或有时java.lang.NullPointerException

看到我的日志了吗

我不明白有时它的工作完美,有时不完美。我用过这个 方法以静态方式进行活动


java.io.IOException:setDataSourceFD失败-音乐文件似乎是以一种奇怪的格式编码的,对于MediaPlayer,所以请尝试将其转换为OGG格式

public class Music implements OnCompletionListener    {

   public static boolean isPlaying=false;

   public static   MediaPlayer mp=null;

public static void playGeneric(int name, final ImageButton button,final ImageButton pervious,Context context) {

    button.setEnabled(false);
    button.setClickable(false);
    pervious.setEnabled(false);
    pervious.setClickable(false);
        try{
            if(isPlaying==true)
            {
                stopplaying();
            }
            if(isPlaying==false)
            {}

              mp = MediaPlayer.create(context, name);
                mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                    @Override
                    public void onPrepared(MediaPlayer arg0) {

                        mp.start(); 
                        isPlaying=true;

                    }

                });
          mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

                @Override
                public void onCompletion(MediaPlayer mp) {
                    // TODO Auto-generated method stub

                    mp.release();
                    isPlaying=false;
                    System.out.println("Object released");
                    button.setEnabled(true);
                    button.setClickable(true);
                    pervious.setEnabled(true);
                    pervious.setClickable(true);
                }
            });




    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        e.getMessage();
    } catch (NullPointerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        e.getMessage();
    }

}

public static void stopplaying() {
        if (mp != null) {
            mp.stop();
            mp.release();
            mp = null;
        }

    }
10-15 15:36:19.061: E/MediaPlayer(5018): Unable to to create media player
10-15 15:36:19.061: D/MediaPlayer(5018): create failed:
10-15 15:36:19.061: D/MediaPlayer(5018): java.io.IOException: setDataSourceFD failed.: status=0x80000000
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.media.MediaPlayer.setDataSource(Native Method)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.media.MediaPlayer.create(MediaPlayer.java:666)
10-15 15:36:19.061: D/MediaPlayer(5018):    at com.rogerscenter.LearnReadWriteSpell.Utility.Music.playGeneric(Music.java:102)
10-15 15:36:19.061: D/MediaPlayer(5018):    at com.rogerscenter.LearnReadWriteSpell.LetterCategory.Letter_Lesson1_activity.onClick(Letter_Lesson1_activity.java:702)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.view.View.performClick(View.java:2485)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.view.View$PerformClick.run(View.java:9153)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.os.Handler.handleCallback(Handler.java:587)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.os.Looper.loop(Looper.java:123)
10-15 15:36:19.061: D/MediaPlayer(5018):    at android.app.ActivityThread.main(ActivityThread.java:3647)
10-15 15:36:19.061: D/MediaPlayer(5018):    at java.lang.reflect.Method.invokeNative(Native Method)
10-15 15:36:19.061: D/MediaPlayer(5018):    at java.lang.reflect.Method.invoke(Method.java:507)
10-15 15:36:19.061: D/MediaPlayer(5018):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-15 15:36:19.061: D/MediaPlayer(5018):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-15 15:36:19.061: D/MediaPlayer(5018):    at dalvik.system.NativeStart.main(Native Method)
10-15 15:36:19.061: W/System.err(5018): java.lang.NullPointerException
10-15 15:36:19.061: W/System.err(5018):     at com.rogerscenter.LearnReadWriteSpell.Utility.Music.playGeneric(Music.java:103)
10-15 15:36:19.061: W/System.err(5018):     at com.rogerscenter.LearnReadWriteSpell.LetterCategory.Letter_Lesson1_activity.onClick(Letter_Lesson1_activity.java:702)
10-15 15:36:19.061: W/System.err(5018):     at android.view.View.performClick(View.java:2485)
10-15 15:36:19.061: W/System.err(5018):     at android.view.View$PerformClick.run(View.java:9153)
10-15 15:36:19.061: W/System.err(5018):     at android.os.Handler.handleCallback(Handler.java:587)
10-15 15:36:19.061: W/System.err(5018):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-15 15:36:19.061: W/System.err(5018):     at android.os.Looper.loop(Looper.java:123)
10-15 15:36:19.061: W/System.err(5018):     at android.app.ActivityThread.main(ActivityThread.java:3647)
10-15 15:36:19.061: W/System.err(5018):     at java.lang.reflect.Method.invokeNative(Native Method)
10-15 15:36:19.061: W/System.err(5018):     at java.lang.reflect.Method.invoke(Method.java:507)
10-15 15:36:19.061: W/System.err(5018):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-15 15:36:19.061: W/System.err(5018):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-15 15:36:19.061: W/System.err(5018):     at dalvik.system.NativeStart.main(Native Method)