Android Media Player streaming - works in emulator, fails on hardware


I'm facing a weird problem related to Android, streaming and Media Player.

The actual app is quite complex, but I have put the simplest possible test case: a 'Hello, World' activity launches Media Player with a hard-coded URL. This works fine in Android emulator, both API level 7 (which is the minimum for the real app) and API level 17. However, the same app fails on a hardware device with API level 15 - Media Player fails during the prepare() call:

  • If using blocking prepare(), it fails with IOException
  • If using non-blocking prepareAsync(), it fails and onErrorListener triggers (no exception is raised).

The failure always (blocking and non-blocking prepare) shows "Error (1,-2147483648)". Media Player docs have no such error code -2147483648 (0xffffffff).

The app has proper permission to access the Internet (android.permission.INTERNET) and the Internet connection of the device is working (the same app can download files from Internet).

This is not a codec issue - because the same stream can be played by the emulator and because any other stream fails in the same way on the hardware device.

Tried many other things of which none helped:

  • Using pepareAsync() and onPreparedListener to call start()
  • Calling reset() on Media Player
  • Setting the data source through Uri.parse()
  • Obtaining audio focus from Audio Manager

Hardware is working properly as the same device can play audio files from its storage using the Android built-in default audio player app.

I don't believe (much) in ghosts, but I'm kinda running out of other options. Anybody seen anything like this? The app working in emulator, but not on hardware?

Can anybody please try this code on a hardware device (I only have 1 Android device)?

public class MainActivity extends Activity {

private MediaPlayer mediaPlayer;
private String listen_url = "";

protected void onCreate(Bundle savedInstanceState) {

    mediaPlayer = new MediaPlayer();

    try {
        //mediaPlayer.setDataSource(this, Uri.parse(listen_url));
    } catch (IllegalArgumentException e) {
    } catch (SecurityException e) {
    } catch (IllegalStateException e) {
    } catch (IOException e) {

    try {
    } catch (IllegalStateException e) {
    } catch (IOException e) {
                    // We fail here!

asked on Stack Overflow Mar 6, 2013 by assen.totin

1 Answer


This is normally because the stream type is not supported by the device you're using. Have you tried a simple MP3 stream?

answered on Stack Overflow Mar 6, 2013 by Geobits

User contributions licensed under CC BY-SA 3.0