MediaPlayer.prepareAsync is not calling OnPreparedListener

All your problems with Audio, Video and Images.

MediaPlayer.prepareAsync is not calling OnPreparedListener

Postby ballaballa1556 » Thu Mar 25, 2010 7:34 pm

Hello all,

I'm working on an application that shall stream mp3 data from internet radio stations.
It does work for some sources already, but it doesn't for others. The code basically
looks like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String Url = ...;
  2.  
  3. MediaPlayer player = new MediaPlayer();
  4.  
  5.  
  6.  
  7. player.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
  8.  
  9. {
  10.  
  11.    @Override
  12.  
  13.    public void onPrepared(MediaPlayer mp)
  14.  
  15.    {
  16.  
  17.       player.start();
  18.  
  19.    }
  20.  
  21. });
  22.  
  23.  
  24.  
  25. player.reset();
  26.  
  27. player.setDataSource(Url);
  28.  
  29. player.setAudioStreamType(AudioManager.STREAM_MUSIC);
  30.  
  31. player.prepareAsync();
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


With Url = "http://mp3.webradio.antenne.de:80/" it works with no problem. But with
Url = "http://scfire-ntc-aa05.stream.aol.com:80/stream/1074" it does not. The
OnPreparedListener never gets called. If I stop the mediaplayer while it is still in
prepareAsync, I get the message

PlayerDriver | Command (6) was cancelled

I have googled quite a bit for a solution but could not find one. The only difference
I found is that the MediaPlayer reports

MediaPlayer | info/warning (1, 44)
MediaPlayer | Info (1,44)

for the ones that work and

MediaPlayer | info/warning (1, 28)
MediaPlayer | Info (1,28)

for the ones that don't. But I have no clue if that's related to this problem at all...
I checked it with SDK 1.6, 2.0 and 2.1. Any idea, why it will play from the first URL
but not from the second?

Thanks a lot in advance!

Andreas
ballaballa1556
Freshman
Freshman
 
Posts: 6
Joined: Thu Mar 25, 2010 6:33 pm

Top

Postby ballaballa1556 » Mon Mar 29, 2010 9:04 am

Hello all,

I guess I found the reason why the MediaPlayer will not play from the
second source: It's because it's a SHOUTcast stream. I'm really surprised
though that the MediaPlayer doesn't support it. The only information I
could find so far on the web about playing this type of stream is to
download chunks of it to files and then play the chunks (Like here:
http://github.com/Dawnthorn/nagare/). But that creates a gap when
switching playback from one file to the next which is not acceptable.

Does anyone have a hint for me on how to implement it without the
gaps?

Thanks!

Andreas
ballaballa1556
Freshman
Freshman
 
Posts: 6
Joined: Thu Mar 25, 2010 6:33 pm

Re: MediaPlayer.prepareAsync is not calling OnPreparedListen

Postby slouma » Tue Jun 01, 2010 12:11 pm

Hello,
I tried your code but I failed to play sound. and I got error on LogCat:

06-01 11:05:52.023: WARN/MediaPlayer(218): info/warning (1, 26)
06-01 11:05:52.023: INFO/MediaPlayer(218): Info (1,26)
06-01 11:05:52.064: ERROR/PlayerDriver(30): Command PLAYER_INIT completed with an error or info PVMFFailure
06-01 11:05:52.064: ERROR/MediaPlayer(218): error (1, -1)
06-01 11:05:52.064: ERROR/MediaPlayer(218): Error (1,-1)
06-01 11:05:52.074: WARN/PlayerDriver(30): PVMFInfoErrorHandlingComplete

can you help me please.

other question, what does (1,26), (1,-1) mean?
thank you
Regards
slouma
Once Poster
Once Poster
 
Posts: 1
Joined: Mon May 31, 2010 11:41 am

Re: MediaPlayer.prepareAsync is not calling OnPreparedListen

Postby tehbrosta » Sun Jun 13, 2010 5:35 pm

I am dealing with a very similar problem... any luck w/ Shoutcast's stream?
tehbrosta
Freshman
Freshman
 
Posts: 6
Joined: Tue Jan 05, 2010 9:15 pm

Re: MediaPlayer.prepareAsync is not calling OnPreparedListen

Postby ballaballa1556 » Mon Jun 21, 2010 9:41 am

Hi,

sorry, no luck so far. And I have no clue what those error messages mean.
I searched the web for information on the error codes but could not find
anything. The java code above might not be complete. I just copied the
relevant parts from my project to show the basic approach. It works for
me for "real" mp3 streams.

As far as I know, shoutcast streams are not much different from http mp3
streams. The return header starts with "icy 200 ok" instead of "http/1.1 200 ok"
and sends a few different fields, but the stream itself is the same. Is that
correct? If true, it's even more surprising that even the newest version of
android does not support shoutcast streams. :(

If anyone gets streaming shoutcasts to work or has any hint on how to do it,
please enlighten us... :)

Thanks

Andreas
ballaballa1556
Freshman
Freshman
 
Posts: 6
Joined: Thu Mar 25, 2010 6:33 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 23 guests