简体   繁体   English

Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1, 无法修复

[英]Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1, cant fix

I've tried a lot of things... but none seem to work.我已经尝试了很多东西......但似乎都没有用。 Most of them from here: Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1其中大部分来自这里: Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1

So I tried to play music using MediaPlayer in android, But the prepare always fails with the same exception.所以我尝试在 android 中使用 MediaPlayer 播放音乐,但准备总是失败并出现相同的异常。 Here is my onStartCommand function:这是我的 onStartCommand 函数:

@Override
    public int onStartCommand(Intent intent,int flags, int startId)
    {
        Toast.makeText(this, "Service on start", Toast.LENGTH_LONG).show();
        String lnk = intent.getExtras().getString("link");
        mediaPlayerM.reset();
        if(!mediaPlayerM.isPlaying())
        {
            try
            {
                mediaPlayerM.setDataSource(lnk);
                mediaPlayerM.setAudioStreamType(AudioManager.STREAM_MUSIC);
                mediaPlayerM.prepare();
            }
            catch (Exception e)
            {
                System.out.print(e.toString());
                Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
            }
        }
        return START_STICKY;
    }

and the onPrepared function:和 onPrepared 函数:

public void onPrepared(MediaPlayer mp)
    {
        if(!mediaPlayerM.isPlaying())
        {
            mediaPlayerM.start();
        }
    }

So basically I try debugging, and everytime variable e (which is the exception) is the same java.io.IOException: Prepare failed.: status=0x1.所以基本上我尝试调试,每次变量 e(这是例外)都是相同的java.io.IOException: Prepare failed.: status=0x1.

Btw, the URL I pass is: http://www.ilemon.mobi/fightnIncastle1.mp3 , which should work fine.顺便说一句,我传递的 URL 是: http://www.ilemon.mobi/fightnIncastle1.mp3 ://www.ilemon.mobi/fightnIncastle1.mp3,应该可以正常工作。

TL;DR: My question, is why does it throw the expectation whenever I USE the mediaPlayer.prepare() method. TL;DR:我的问题是,为什么每当我使用 mediaPlayer.prepare() 方法时它都会引发期望。 I pass the URL using setDataSource.我使用 setDataSource 传递 URL。 and prepare should call onPrepared when it is ready to play audio... but again, the exception happens, for some reason.并且 prepare 应该在准备好播放音频时调用 onPrepared ...但是由于某种原因再次发生异常。 And I'm not sure why it happens.... that's what I'm asking.而且我不确定为什么会这样……这就是我要问的。 (I have all the permissions in the manifest) (我拥有清单中的所有权限)

Try using https://www.ilemon.mobi/fightnIncastle1.mp3 as the URL.尝试使用https://www.ilemon.mobi/fightnIncastle1.mp3作为 URL。 I suspect it's something to do with non-https stream.我怀疑这与非 https 流有关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.IOException:准备失败。:状态= 0x1 - java.io.IOException: Prepare failed.: status=0x1 java.io.IOException:准备失败。:Android中的status = 0x1 - java.io.IOException: Prepare failed.: status=0x1 in Android java.io.IOException:准备失败:状态= 0x1 - java.io.IOException:prepared failed:status=0x1 Android MediaPlayer return Prepare failed.: status=0x1 on device but running in emulator - Android MediaPlayer return Prepare failed.: status=0x1 on device but runs in emulator 无法使用java.io.IOException创建媒体播放器:setDataSourceFD失败:状态= 0x80000000在2.3.3安卓平板电脑 - Unable to to create media player with java.io.IOException: setDataSourceFD failed.: status=0x80000000 in 2.3.3 android tablet 使用SurfaceView仅在三星GT-I8260中渲染视频时出现问题。 IOException:准备失败。:status = 0x1 - Problems rendering video only in Samnsung GT-I8260 using SurfaceView. IOException: Prepare failed.: status=0x1 java.io.IOException:setdatasource失败状态= 0xFFF - java.io.IOException:setdatasource failed status = 0xFFF java.io.IOException:HTTP请求失败,HTTP状态:500使用WCF for android在android中 - java.io.IOException: HTTP request failed, HTTP status: 500 in android using WCF for android 如何修复/避免java.io.IOException:套接字读取失败? - How to fix/avoid java.io.IOException: Socket read failed? java.io.IOException:所有收集器的初始化失败。 最后一个收集器中的错误是:null - java.io.IOException: Initialization of all the collectors failed. Error in last collector was :null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM