7

I use MediaPlayer to play mp3 stream via http. On some specific devices it doesn't reach the end of the stream too often. Just stops. It occurs only on 2.3.x, can not catch this problem on Jelly Bean. The only strange lines in logcat:

02-04 17:34:14.379: ERROR/HTTPStream(95): recv failed, server is gone, total received: 54683 bytes
02-04 17:34:14.379: ERROR/HTTPStream(95): recv failed, errno = 9 (Bad file number)
02-04 17:34:14.379: ERROR/NuCachedSource2(95): source returned error -1004

OnCompletionListener is called (too early)

Seems like it downloads only 5MB of the stream and doesn't try do download more.

Happens mostly on Samsung Galaxy Ace devices.

Fedor
  • 43,261
  • 10
  • 79
  • 89
Taras
  • 507
  • 1
  • 6
  • 17
  • Have the same problem. Mostly on Samsung Galaxy Ace. – Fedor Sep 21 '13 at 08:19
  • @Fedor I have a suggestion for you, but I'd like to know some specifics about what exactly causes the problem. Is it simple HTTP streaming? Is it only certain streams, or all streams? – Dave Nov 28 '13 at 09:17
  • @Dave It works this way for all streams I tested. – Fedor Nov 28 '13 at 11:31
  • 1
    @Fedor It looks to me like there is an issue with buffer overflow on that device, such that when the buffer is full and it can't read new data it thinks the server has closed. The error that's printed out is because of a read that returns -1, but a full buffer should normally return 0. Like many problems with MediaPlayer, I think you can solve this by putting a local proxy on the device so that you have more control over the data that is streamed. See my answer [here](http://stackoverflow.com/questions/12701249/getting-access-to-media-player-cache/18627606#18627606). – Dave Nov 28 '13 at 14:01
  • After you have a local proxy, you can buffer the data yourself and limit what goes to the player. I've done exactly that for video on an embedded system, and it works quite well for what I've needed. – Dave Nov 28 '13 at 14:06

1 Answers1

2

you can try this android media player connecting status with audio streaming link(ie 2%,4%...100% then online radio start to play) in android

this perfectly play streaming mp3 via http. or just go http://coderfriend.blogspot.com/ blog.

Community
  • 1
  • 1