Android的MediaPlayer的错误:MediaPlayer的错误(1,-2147483648)的流从互联网 [英] Android MediaPlayer error: MediaPlayer error(1, -2147483648) on Stream from internet
问题描述
我想流从URL的音频。在code正常工作与其他URL,但在其中的一个失败的在prepared
方法,返回此错误code:(1 ,-2147483648)。我读过一些人说这是因为权限的,但它是一个远程文件,所以我不能设置权限。我试着与其他应用程序,如VLC和iTunes的URL,它的正常工作。我的code是在这里:
私人无效prepareradio(){
球员=新的MediaPlayer();
player.setAudioStreamType(MODE_WORLD_READABLE);
尝试 {
player.setDataSource(URL);
}赶上(抛出:IllegalArgumentException E){
e.printStackTrace();
}赶上(IllegalStateException异常E){
e.printStackTrace();
}赶上(IOException异常E){
e.printStackTrace();
}
player.setOnErrorListener(新OnErrorListener(){
公共布尔的onError(MediaPlayer的为arg0,诠释ARG1,ARG2 INT){
Toast.makeText(getApplicationContext(),发生了一个错误,而preparing电台,Toast.LENGTH_LONG).show();
prepareradio();
playe.setEnabled(真正的);
hidenot();
返回false;
}
});
如果您在设备上测试之前的Android 3.1,你可能无法发挥AACP(所看到的信息页面为你流的(AAC +)流。
信息页面为你流:
为了找出流,你可以在目标设备上播放查看官方文档:的 http://developer.android.com/reference/android/media/AudioManager.html
如果您正在寻找如何处理如下AACP结帐:
http://stackoverflow.com/a/8833346/200272
I'm trying to stream audio from a URL. The code works fine with other URLs, but in one of those it fails in the OnPrepared
method, returning this error code: (1, -2147483648). I've read some people saying it's because of permissions, but it's a remote file, so I can't set permissions. I've tried the URL with other apps like VLC and iTunes, and it's working fine. My code is here:
private void prepareradio() {
player = new MediaPlayer();
player.setAudioStreamType(MODE_WORLD_READABLE);
try {
player.setDataSource(url);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player.setOnErrorListener(new OnErrorListener(){
public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
Toast.makeText(getApplicationContext(),"An error happened while preparing radio",Toast.LENGTH_LONG).show();
prepareradio();
playe.setEnabled(true);
hidenot();
return false;
}
});
If you are testing on devices earlier than Android 3.1 you might not be able to play AACP (as seen on the info page for your stream (AAC+) streams.
Info page for your stream:
In order to find out what streams you can play on your targeted device check official docs: http://developer.android.com/reference/android/media/AudioManager.html
If you are looking how to handle aacp checkout following:
http://stackoverflow.com/a/8833346/200272
这篇关于Android的MediaPlayer的错误:MediaPlayer的错误(1,-2147483648)的流从互联网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!