android error (1, -2147483648),Android MediaPlayer error: MediaPlayer error(1, -2147483648) on Strea...

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

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; } });

回答1:

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:

504b1228f6c33f3970d5908fd848e91a.png

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:

https://stackoverflow.com/a/8833346/200272

回答2:

I was also getting the same error on Froyo & Gingerbread. In higher Androids the same video played well. Finally after a lot of research, tried changing the Https Url to Http Url & Bingo. It resolved my issue. I was using amazon S3 server so that simply replacing the "https" in url with "http" was sufficient. videoUrl= videoUrl.replaceFirst("https", "http");

PS: For supporting older versions if you are using H.264 make sure videos are Baseline encoded.

回答3:

As I can see, this stream is not supported by mediaPlayer. Android supports AAC LC/LTP but your stream is aacp. I think this may be the root cause of your problem.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值