I'm able to play Icecast2 url in 4.1+ versions, but in earlier versions it's throwing IOException.
I've used this code to play audio stream.
try { this.mPlayer = new MediaPlayer(); this.mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); //this.mPlayer = MediaPlayer.create(context,Uri.parse("http://176.31.115.196:8214/")); this.mPlayer = MediaPlayer.create(context, Uri.parse("http://184.107.191.197:8065/live")); this.mPlayer.setOnPreparedListener(new OnPreparedListener() { public void onPrepared(MediaPlayer mp) { mp.start(); } }); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } catch (Exception e) { Log.d(TAG, "Exception: " + e.getMessage()); }
I got this Exception..
error (1, -2147483648)
create failed:
java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer.prepare(Native Method)
at android.media.MediaPlayer.create(MediaPlayer.java:632)
at android.media.MediaPlayer.create(MediaPlayer.java:609)
at com.Rcc.Common.UserPublicData.createNewMediaPlayer(UserPublicData.java:170)
at com.Rcc.Submain.PlaySubview$PrepareStream.doInBackground(PlaySubview.java:837)
at com.Rcc.Submain.PlaySubview$PrepareStream.doInBackground(PlaySubview.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
Exception: null
The other url works fine, only problem with the icecast url. Please nothe that url works fine in JellyBean versions.