Android Streaming Wav Audio Error: MediaPlayer Prepare failed: status=0x1

Home - Android Streaming Wav Audio Error: MediaPlayer Prepare failed: status=0x1

Girly Saputri Staff asked 10 months ago

We are streaming audio via http from ffserver/ffmpeg on Angstrom Linux. The ffmpeg audio codec is PCM signed 16-bit little endian “pcm_s16le”. The ffmpeg stream format is “wav”. Both of these are claimed to be supported on Android here: http://developer.android.com/guide/appendix/media-formats.html#core

VLC finds and plays the stream without any problems. Under VLC “Codec Details”, it says: Type: Audio, Codec: PCM S16 LE (araw) Channels: Stereo Sample rate: 48000 Hz Bits per sample: 16

We built the simple test application below to pick up and play the stream in Android and get this error: java.io.IOException: Prepare failed.: status=0x1

We checked the HTTP header using HTTP Debugger Pro. The Response Header items (when playing normally via VLC) are: [Response]: HTTP/1.0 200 OK Pragma: no-cache Content-Type: audio/x-wav

We have been searching the web for help on this issue for over two days and have come up empty-handed. Any help would be greatly appreciated.

————TEST APP———————— package com.shaneahern.streamtest; import java.io.IOException; import android.app.Activity; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Bundle; import android.util.Log;

public class BareBonesStreamTestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

 

Start your code here
String streamUrl = "http://192.168.24.123:8080/test.wav"; 

    MediaPlayer mp = new MediaPlayer(); 
    Log.i("BareBonesStreamTestActivity", "MediaPlayer created"); 

    try { 
        mp.setDataSource(streamUrl); 
        Log.i("BareBonesStreamTestActivity", "setDataSource to " + streamUrl); 

        mp.setAudioStreamType(AudioManager.STREAM_MUSIC); 
        Log.i("BareBonesStreamTestActivity", "setAudioStreamType to AudioManager.STREAM_MUSIC"); 

        mp.prepare(); 
        Log.i("BareBonesStreamTestActivity", "prepare succeeded, calling start"); 

        mp.start(); 
    } catch (IllegalStateException e) { 
        Log.i("BareBonesStreamTestActivity", "prepare failed with IllegalStateException"); 
        e.printStackTrace(); 
    } catch (IOException e) { 
        Log.i("BareBonesStreamTestActivity", "prepare failed with IOException"); 
        e.printStackTrace(); 
    } 
} 
Your Answer