Wowza Community

Unable to play stream with android.media.MediaPlayer

I’m trying to play an AAC audio stream from an Android app, but I’m unable to get it playing.

MediaPlayer player = new MediaPlayer();
player.reset();
player.setDataSource("rtsp://1.2.3.4/app/stream");
player.prepare();
player.start();

It sits at prepare() for 15-20 seconds, then it dies:

W/MediaPlayer(  667): info/warning (1, 26)
I/MediaPlayer(  667): Info (1,26)
E/PlayerDriver(   31): Command PLAYER_PREPARE completed with an error or info PVMFFailure
E/MediaPlayer(  667): error (1, -1)
E/MyTest    (  667): java.io.IOException: Prepare failed.: status=0x1
E/MyTest    (  667): 	at android.media.MediaPlayer.prepare(Native Method)
E/MyTest    (  667): 	at com.example.android.skeletonapp.SkeletonActivity$4.run(SkeletonActivity.java:133)
E/MyTest    (  667): 	at java.lang.Thread.run(Thread.java:1096)
W/PlayerDriver(   31): PVMFInfoErrorHandlingComplete
E/MediaPlayer(  667): start called in state 0
E/MediaPlayer(  667): error (-38, 0)
E/MediaPlayer(  667): Error (-38,0)

It seems MediaPlayer will only try to use UDP as transport. Is it possible to force it to use TCP?

MediaPlayer doesn’t like http://1.2.3.4/app/stream/playlist.m3u8 at all either, since it doesn’t seem to support parsing of m3u playlists. Are there other URLs I could try?

Both of these URLs play just fine in VLC.

Have you tested the rtsp url in VLC 1.05? Or the rtmp version in the Wowza example player?

Are there any corresponding logs in Wowza that are useful?

What version of Android? If it is 2.2, have you tried rtmp to Flash 10.1 application?

Richard

First, be sure you have caerfully gone through all the steps outline here:

https://www.wowza.com/docs/how-to-troubleshoot-rtsp-rtp-playback)

It is very important that UDP is wide, wide, wide open. If you are behind NAT map all UDP ports to the machine running Wowza.

First, try out test stream. It is here:

http://www.wowza.com/mobile.html

I would focus on getting RTSP to play in the browser first. Then move on to trying it through the API. I do not believe the Android support RTSP/RTP interleaved (RTP over TCP). I have an Android I am not able to get it to fail over to TCP. So it is important to get the UDP routing sorted out.

Charlie

I am really not sure about the Android versions, but I do know that carrier and network are also big factors as to what works and what doesn’t. You might get Android 1.5 to work in some cases and not in others.

I do know that Android 2.2 supports Flash 10.1, which is the Flash plugin (runtime) that Flash apps run in (Like the Wowza Flash example players, JW Player, Flowplayer, etc), so it should be easier to stream to Android 2.2 to a Flash app then with rtsp.

You don’t need to downgrade VLC if it is working for your purposes.

In any case, review these guides:

https://www.wowza.com/docs/how-to-set-up-an-application-for-rtsp-rtp-streaming

https://www.wowza.com/docs/how-to-troubleshoot-rtsp-rtp-playback)

Richard

Is there a way to make the server deliver more data at the beginning of a song, to fill the client side buffer faster?

For RTSP, there is not a way to do this at this time.

Richard

Henrik,

That makes a lot of sense - we’ve had a lot of folks who have had trouble with the emulator playing video correctly.

Thanks for the swift reply, Richard.

As I mentioned, it played fine in VLC. I used the latest version (v1.1.3), though, should I downgrade to 1.0.5?

I’ve tried on Android 1.5, 1.6 and 2.1. I’ll try 2.2 tomorrow, but I need this to work on 1.5+.

I have not tried “rtmp to Flash 10.1 application”, what is that? I guess it’s not something I can bundle with my application?

The thing is; we have an existing media player running on Android (1.5+) and several other platforms (iPhone, Windows, MacOSX, …), and a large number of existing users. We are considering replacing our existing streaming server something else, e.g. with Wowza. This means that we cannot go for an Android 2.2-only approach, since just a fraction of our users have access to 2.2. Similarly, we won’t be able to replace our existing application with a completely new Flash-on-Android implementation.

I’m sure http or rtsp streaming to our Android client with the Wowza backend should work somehow. I just don’t know how.

It looks like this was a PEBCAK problem after all.

I just discovered that everything worked as intended when I tested on my phone using 3G. On the Android Emulator through the internal wifi network, on the other hand…

Thanks for you patience!

Another thing: Before wowza I used play HTTP progressive download, which gave me ~1 second buffering delay when playing a song. Now, with RTSP and wowza, there’s a 4-7 second buffering delay. There doesn’t seem to be a way to tweak the buffer settings in android.media.MediaPlayer. Is there a way to make the server deliver more data at the beginning of a song, to fill the client side buffer faster?

You must use prepareAsync() instead prepare() for streaming reproduction. Please note in android documentation is request that you implemented a listener to know when the media is prepared to reproduce.

Regards.