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

We stream audio via http from ffserver / ffmpeg to Angstrom Linux. The ffmpeg audio codec is PCM signed with the 16-bit small trailing pcm_s16le. The ffmpeg stream format is "wav". Both of them are allegedly supported on Android here: http://developer.android.com/guide/appendix/media-formats.html#core

VLC finds and plays the stream without any problems. The VLC "Codec Details" section says: Type: Audio, Codec: PCM S16 LE (araw) Channels: Stereo Sampling frequency: 48000 Hz Bits per sample: 16

We created a simple test application below to pick up and play a stream in Android and get this error: java.io.IOException: Failed to prepare: status = 0x1

We checked the HTTP header using HTTP Debugger Pro. Response header elements (during normal playback via VLC): [Response]: HTTP / 1.0 200 OK Pragma: no-cache Content-Type: audio / x-wav

We searched the Internet for help on this issue for more than two days and came 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;

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

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(); } } 

}

------------ ERROR LOG ------------------------

 I/BareBonesStreamTestActivity( 727): MediaPlayer created I/StagefrightPlayer( 33): setDataSource('http://192.168.24.123:8080/ test.wav') I/BareBonesStreamTestActivity( 727): setDataSource to http://192.168.24.123:8080/test.wav I/BareBonesStreamTestActivity( 727): setAudioStreamType to AudioManager.STREAM_MUSIC E/MediaPlayer( 727): error (1, -2147483648) I/BareBonesStreamTestActivity( 727): prepare failed with IOException W/System.err( 727): java.io.IOException: Prepare failed.: status=0x1 W/System.err( 727): at android.media.MediaPlayer.prepare(Native Method) W/System.err( 727): at com.shaneahern.streamtest.BareBonesStreamTestActivity.onCreate(BareBonesStr eamTestActivity.java: 30) W/System.err( 727): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1047) W/System.err( 727): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2627) W/System.err( 727): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2679) W/System.err( 727): at android.app.ActivityThread.access $2300(ActivityThread.java:125) W/System.err( 727): at android.app.ActivityThread $H.handleMessage(ActivityThread.java:2033) W/System.err( 727): at android.os.Handler.dispatchMessage(Handler.java:99) W/System.err( 727): at android.os.Looper.loop(Looper.java:123) W/System.err( 727): at android.app.ActivityThread.main(ActivityThread.java:4627) W/System.err( 727): at java.lang.reflect.Method.invokeNative(Native Method) W/System.err( 727): at java.lang.reflect.Method.invoke(Method.java:521) W/System.err( 727): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) W/System.err( 727): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) W/System.err( 727): at dalvik.system.NativeStart.main(Native Method) 
+6
source share
2 answers

I think you can take a look at: Using AudioTrack to play a wav file

Another useful link

I downloaded the raw stream myself and it works well.

+1
source

Although it's already late, I also got the same error when working with MediaPlayer .

After some R&D, I found the source of the problem. For the future, I record it to answer the field

In my case, this happened because I gave UnSupported File to MediaPlayer.

So, if that happens, make sure your file is right.

Other reasons:

  • File path error, invalid URI or directory
  • Resolution problem
0
source

Source: https://habr.com/ru/post/892623/


All Articles