媒体播放器称为状态0,错误(-38,0) [英] Media Player called in state 0, error (-38,0)

查看:661
本文介绍了媒体播放器称为状态0,错误(-38,0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在设计一个简单的应用程序,流的网络电台。我的URL站和正在建立的媒体播放器一样。

I am currently trying to design a simple app that streams an internet radio station. I have the URL for the station and am setting up the Media Player like

    MediaPlayer mediaPlayer = new MediaPlayer();
    try {
        mediaPlayer.setDataSource(URL);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        mediaPlayer.prepare();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    mediaPlayer.start();

该程序没有崩溃仿真的时候,但没有什么是玩,我收到以下错误:

The program isn't crashing when emulated, but nothing is playing and I am get the following error:

start called in state 0

和右下方是

Error (-38,0)

有谁知道这是什么意思?

Does anyone know what this means?

我读过一些关于这些国家的错误,但无法找到适用于我的项目什么。

I've read a little about these state errors, but couldn't find anything that applies to my project.

推荐答案

编辑:我知道的这是一个无用的答案,但我无法删除它,因为它是公认的答案。 OP应当标注另一个答案被接受的。

I know this is a useless answer but I am unable to delete it as it is the accepted answer. OP should mark another answer as the accepted.

我想你应该设置使用错误监听<一href="http://developer.android.com/reference/android/media/MediaPlayer.html#setOnErrorListener(android.media.MediaPlayer.OnErrorListener)"相对=nofollow> setOnErrorListener ,看看你打电话时,你得到任何错误的setDataSource

I think you should set an error listener using setOnErrorListener to see if you get any error when calling setDataSource.

这篇关于媒体播放器称为状态0,错误(-38,0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆