Question

My application plays ShoutCast Streaming and the target OS is 1.6 and above. I have applied some code from NPR application with some modification.

Here is the code

mediaPlayer = new MediaPlayer();
mediaPlayer.reset();
mediaPlayer.setDataSource(url);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
// Log.d(LOG_TAG, "Preparing: " + playUrl);
mediaPlayer.prepareAsync();
mediaPlayer.start();`

The code doesnot play anything on simulator or device(Testing in Samsung Galaxy with 2.1).


Here is the LogCat message.

About to play http://88.191.81.31:8206
12-08 14:16:42.229: WARN/MediaPlayer(5520): info/warning (1, 26)
12-08 14:16:42.239: ERROR/PlayerDriver(1870): Command PLAYER_INIT completed with an error or info PVMFFailure
12-08 14:16:42.239: ERROR/MediaPlayer(5520): error (1, -1)
12-08 14:16:42.239: WARN/PlayerDriver(1870): PVMFInfoErrorHandlingComplete
12-08 14:16:42.259: ERROR/MediaPlayer(5520): start called in state 0
12-08 14:16:42.259: ERROR/MediaPlayer(5520): error (-38, 0)
12-08 14:16:42.299: INFO/MediaPlayer(5520): Info (1,26)
12-08 14:16:42.299: ERROR/MediaPlayer(5520): Error (1,-1)
12-08 14:16:42.304: ERROR/MediaPlayer(5520): Error (-38,0)


Here is the question. 1. Can you tell me whats happening in device? 2. How to solve this error?.

Was it helpful?

Solution

You are calling start() too soon. Javadocs of MediaPlayer explain it (look at the picture):

  1. Either you have to call prepare() before you call start(), or

  2. You call prepareAsync() and wait for OnPreparedListener.onPrepared() to be called, then (possibly inside this method) call start().

Updated:

Shoutcast streams are nativelly supported only on 2.2. For earlier versions you must create local proxy that changes the response protocol from ICY (shoutcast) to HTTP, which the mediaplayer will support. Take a look at this:

http://code.google.com/p/npr-android-app/source/browse/trunk/Npr/src/org/npr/android/news/StreamProxy.java

This has previously been discussed:

Listen to a shoutcast with Android

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top