我在播放在线广播流时收到一个异常

mrfwxfqh  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(182)

我正在尝试使用android的mediaplayer播放在线音频流。但是每次我尝试播放流时都会收到ioexception。流url可以在setdatasource方法中找到,并且可以粘贴到您最喜欢的浏览器中进行播放。

MediaPlayer mediaPlayer = new MediaPlayer();
        try {
            mediaPlayer.setAudioAttributes(new AudioAttributes.Builder()
                    .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                    .setUsage(AudioAttributes.USAGE_MEDIA)
                    .build());
            mediaPlayer.setDataSource("https://iceant.antfarm.co.za/EdenFM");
            mediaPlayer.prepare();
            mediaPlayer.start();
        } catch (IOException e) {
            e.printStackTrace();
        }

以下是我得到的一个例外:

2021-07-08 15:09:25.372 13679-13679/za.co.ezimax.ezimax W/System.err: java.io.IOException: Prepare failed.: status=0x1
2021-07-08 15:09:25.372 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.media.MediaPlayer._prepare(Native Method)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.media.MediaPlayer.prepare(MediaPlayer.java:1276)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at za.co.ezimax.radio.RadioActivity.onCreate(RadioActivity.java:81)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.Activity.performCreate(Activity.java:8000)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.Activity.performCreate(Activity.java:7984)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.os.Looper.loop(Looper.java:223)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7656)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2021-07-08 15:09:25.373 13679-13679/za.co.ezimax.ezimax W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
202

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题