I have developed an Android music player app that can stream MP3s via HTTP progressive download (via WiFi, using Apache). This is how I set up the MediaPlayer
to stream the MP3:
mediaplayer.setDataSource(192.168.../song.mp3)
Everything works fine until the connection to the server is lost. From the log outputs of my registered onBufferingUpdateListener
, it seems that when the connection to the server is lost (say, I turn off WiFi on my phone), MediaPlayer
attempts to fill up the remaining song in its buffer. However this retrying stops after a few seconds.
In other words, if a connection to the server is not resumed within a few seconds of it being lost, MediaPlayer
will not resume buffering. (i.e. onBufferingUpdate()
stops getting called after a few seconds of retrying). Also, I receive no errors/info messages in my onInfoListener
or onErrorListener
.
The question is: How do I force MediaPlayer
to resume buffering the rest of the song(preferably without interrupting playback) when a connection to the server is available again regardless of the time interval between successive connections?
What alternatives do I have to stream MP3s via HTTP progressive download?