Reputation: 2698
I use MediaPlayer
to stream mp3 radio station , it works fine on all android versions except in Android 4.0 it throw this exception
05-28 19:29:57.160: E/MediaPlayer(6854): Unable to to create media player
05-28 19:29:57.164: W/System.err(6854): java.io.IOException: setDataSource failed.: status=0x80000000
05-28 19:29:57.164: W/System.err(6854): at android.media.MediaPlayer.setDataSource(Native Method)
05-28 19:29:57.164: W/System.err(6854): at biz.dot.hayatfm.RadioPlayerService$1.run(RadioPlayerService.java:50)
05-28 19:29:57.168: W/System.err(6854): at java.lang.Thread.run(Thread.java:856)
here is the code
this.mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
this.mediaPlayer.setDataSource( Uri.parse("http://vpr.streamguys.net/vpr96.mp3").toString());
this.mediaPlayer.prepare();
this.mediaPlayer.start();
Upvotes: 2
Views: 581
Reputation: 13327
the IOException
you got infer that the MediaPlayer
class uses a URL
to stream and it can access it so it will throw an IOException
android 4.0 need the internet permission to stream form url this was not the case for pre android 4.0 so you could stream music as you want without that permission.
to fix this include this permssion in your manifest file
<uses-permission android:name="android.permission.INTERNET" />
Upvotes: 2