Reputation: 2809
I've problem with streaming some songs in my android application.
Here is my test code for creating MadiaPlayer
and setting data source:
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.setOnCompletionListener(this);
mediaPlayer.setOnErrorListener(this);
mediaPlayer.setDataSource("http://streaming.ibroadcast.com/?file=MjA1MTIyMS0xMDA1NDQ1NC01MDYxNjY5LTEwMDAwMDQ=");
try {
mediaPlayer.prepare();
} catch (Exception ex) {
Log.e(Constants.LOG_TAG, ex.getMessage(), ex);
}
I get this on mediaPlayer.prepare()
:
10-31 15:41:27.130: ERROR/NuCachedSource2(174): source returned error -32, 0 retries left
10-31 15:41:34.388: ERROR/NuCachedSource2(174): source returned error -32, 0 retries left
10-31 15:41:37.371: ERROR/MediaPlayer(5360): error (1, -2147483648)
10-31 15:41:37.381: ERROR/log_tag (5360): Prepare failed.: status=0x1
java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer.prepare(Native Method)
I've tryed to stream a bunch of songs using this code and this problem occures only for three or four songs, but it's 100% reproducable for that songs. What is more, if I download this songs to SD card and play it from there it plays without any errors. I also able to stream it using browser. All songs has mp3
format and server response contains headers like this:
Accept-Ranges: bytes
Connection: close
Content-Length: 5 MB
Content-Type: audio/mpeg
Date: 2013 Oct 31 14:43:01-8s
ETag: 831c011006861dc9b2fc89ef185f2f4b
Last-Modified: 2013 Aug 28 18:28:31-63d 21h
Server: Apache/2.2.25 (Amazon)
Does anyone has ideas what is wrong?
UPDATE:
Here is not working song first 1024 bytes and here is working one
Upvotes: 0
Views: 6220
Reputation: 8978
After analising HEX samples it reveals that your "working" file is as expected
MPEG-1 Audio Layer 3 with ID3v2 Tag (.mp3 file)
but the "not working" one isn't mp3 but MPEG-1 Audio Layer 2 (.mp2 file)
. According the Android Supported Media Formats it isn't supported. It may even have a .mp3 extension but inside it is not a mp3 file.
Upvotes: 3