我正在为一家实现网络广播的发行商编写一个播放shoutcast流的android应用程序。
在API8级(Android2.2)上,MediaPlayer类可以播放流,所以:
Uri myUri = ....; // initialize Uri here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(getApplicationContext(), myUri);
mediaPlayer.prepare();
mediaPlayer.start();在真实的应用程序中,我使用的是prepareasync(),所以UI可以响应ProgressDialog。
但在本例中,prepare()是可以的。
现在..。在Android < 2.2 (API级别< 8)上,mediaplayer不能播放。在安卓>= 2.2 (API级>= 8)上播放mediaplayer,但不是在所有设备上。
此代码在以下方面工作:
Nexus One (CyanogenMod 7,安卓2.3.x)三星Galaxy S(库存Rom,安卓2.3.x)三星Galaxy S 2(库存Rom,安卓2.3.x) HTC Desire (库存Rom,安卓2.3.x) HTC Desire HD (库存Rom,安卓2.3.x)仿真器(安卓2.2)华硕eee Pad Transformer TF101 (库存Rom,安卓4.0.3)
这段代码并不是在每一个Android >2.2的LG设备上都能运行...但是..。为什么?
如何在LG设备上播放shoutcast strem?
发布于 2012-03-20 04:30:03
我用LG手机和shoutcast也遇到了同样的问题。它准备(),然后抛出一个错误,因为媒体播放器已经崩溃。我在LG的网站上看了看,但找不到他们提供的任何文档或开发领域的帮助。有没有人知道LG在做什么不同,以及如何让它工作?
https://stackoverflow.com/questions/9514487
复制相似问题