Android 媒体播放器在棒棒糖设备中不工作

Android 媒体播放器在棒棒糖设备中不工作,android,android-mediaplayer,Android,Android Mediaplayer,我正在尝试通过媒体播放器播放音频文件。它在棉花糖装置中起作用。不幸的是,它在棒棒糖装置中不起作用。它显示一个IOExceptionjava.io.IOException:Prepare failed.:status=0x105。我不明白会有什么问题。我知道这是个常见的问题。但是我没有从旧问题中得到任何解决方案 try { mPlayer.setDataSource(mChapter.getChapterAudioLink()); } cat

我正在尝试通过媒体播放器播放音频文件。它在棉花糖装置中起作用。不幸的是,它在棒棒糖装置中不起作用。它显示一个IOException
java.io.IOException:Prepare failed.:status=0x105
。我不明白会有什么问题。我知道这是个常见的问题。但是我没有从旧问题中得到任何解决方案

   try {
         mPlayer.setDataSource(mChapter.getChapterAudioLink());
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                    Toast.makeText(context, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
                } catch (SecurityException e) {
                    e.printStackTrace();
                    Toast.makeText(context, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                    Toast.makeText(context, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
                } catch (IOException e) {
                    e.printStackTrace();
                }
   try {

                    mPlayer.prepare();
                    mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                        @Override
                        public void onPrepared(MediaPlayer mediaPlayer) {
                            playOrPause.setImageResource(android.R.drawable.ic_media_pause);
                            mAudioDialog.show();
                            mPlayer.start();
                            mDurationTextView.setText(convertSecondsToHMmSs(mPlayer.getDuration()) + "");
                            mSeekbarAudio.setMax(mPlayer.getDuration());
                        }
                    });
                    //   mPlayer.prepareAsync();
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                    Toast.makeText(context, "You might not set the URI correctlyyy!", Toast.LENGTH_LONG).show();
                } catch (IOException e) {
                    e.printStackTrace();
                    Toast.makeText(context, "You might not set the URI correctlyy!", Toast.LENGTH_LONG).show();
                }

我收到最后一个IOException。

URL中的空格为我造成了此问题。我用
%20
替换了空格,效果很好

mPlayer.setDataSource(mChapter.getChapterAudioLink().replaceAll(" ","%20"));

URL中的空格导致我出现此问题。我用
%20
替换了空格,效果很好

mPlayer.setDataSource(mChapter.getChapterAudioLink().replaceAll(" ","%20"));

你的mp3文件源在哪里?我已经从Web服务设置了uri。它正在进入mChapter。getChapterAudioLink()你解决了吗?是的……我已经发布了答案。你的mp3文件源在哪里?我已经从Web服务设置了uri。它正在进入mChapter。getChapterAudioLink()你解决了吗?是的……我已经发布了答案