# Unable to play stream with android.media.MediaPlayer

**URL:** https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585
**Category:** Wowza Streaming Engine
**Tags:** media-players-and-devices
**Created:** [October 7, 2010, 1:06pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585 "2010-10-07T13:06:52Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Henrik\_Aronsen](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@Henrik\_Aronsen](https://community.wowza.com/u/Henrik_Aronsen)
#### Post date: [October 7, 2010, 1:06pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/1 "2010-10-07T13:06:52Z")

</div>

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

```auto
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:

```auto
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](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.

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [October 7, 2010, 1:15pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/2 "2010-10-07T13:15:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [October 8, 2010, 4:20am UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/3 "2010-10-08T04:20:58Z")

</div>

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

[https://www.wowza.com/docs/how-to-troubleshoot-rtsp-rtp-playback](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:

[https://www.wowza.com/mobile.html](https://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

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [October 7, 2010, 9:43pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/4 "2010-10-07T21:43:36Z")

</div>

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-set-up-an-application-for-rtsp-rtp-streaming)

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

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [October 11, 2010, 6:41pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/5 "2010-10-11T18:41:06Z")

</div>

> 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

---

<div class="post-metadata">

### Author: ![Ian\_Beyer](https://avatars.discourse-cdn.com/v4/letter/i/e99b99/32.png) [@Ian\_Beyer](https://community.wowza.com/u/Ian_Beyer)
#### Post date: [October 11, 2010, 7:41am UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/6 "2010-10-11T07:41:09Z")

</div>

Henrik,

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

---

<div class="post-metadata">

### Author: ![Henrik\_Aronsen](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@Henrik\_Aronsen](https://community.wowza.com/u/Henrik_Aronsen)
#### Post date: [October 7, 2010, 9:15pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/7 "2010-10-07T21:15:31Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Henrik\_Aronsen](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@Henrik\_Aronsen](https://community.wowza.com/u/Henrik_Aronsen)
#### Post date: [October 8, 2010, 7:52am UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/8 "2010-10-08T07:52:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Henrik\_Aronsen](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@Henrik\_Aronsen](https://community.wowza.com/u/Henrik_Aronsen)
#### Post date: [October 11, 2010, 9:46am UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/9 "2010-10-11T09:46:12Z")

</div>

It looks like this was a [PEBCAK](http://en.wikipedia.org/wiki/PEBCAK#Acronyms_and_other_names_for_a_user_error) 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!

---

<div class="post-metadata">

### Author: ![Henrik\_Aronsen](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@Henrik\_Aronsen](https://community.wowza.com/u/Henrik_Aronsen)
#### Post date: [October 11, 2010, 12:16pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/10 "2010-10-11T12:16:15Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Bruno\_Bourbon](https://avatars.discourse-cdn.com/v4/letter/b/dbc845/32.png) [@Bruno\_Bourbon](https://community.wowza.com/u/Bruno_Bourbon)
#### Post date: [November 5, 2010, 4:26pm UTC](https://community.wowza.com/t/unable-to-play-stream-with-android-media-mediaplayer/35585/11 "2010-11-05T16:26:09Z")

</div>

You must use **prepareAsync(**) instead **prepare()** for streaming reproduction. Please note in [android documentation](http://developer.android.com/reference/android/media/MediaPlayer.html) is request that you implemented a listener to know when the media is prepared to reproduce.

Regards.
