Android Player

04 May 2010

We ran into some difficulties when developing an Android audio streaming app. The standard MediaPlayer wouldn’t play audio from our stream, because of its stream type. The stream’s content type we had to work with was "application/octet-stream" whereas Standard MediaPlayer works only with the content-type "audio/mpeg".

To solve the problem, we tried to use the StreamingMediaPlayer class that can play out audio streams sequentially, part by part. We came up with a following workaround solution: The Streaming Player incrementally downloads the audio stream from the URL into the buffer. As soon as the buffer is full the MediaPlayer starts to play in the background while the Streaming Player continues to download the stream. When the MediaPlayer reaches the end of the buffered audio, newly downloaded audio is transferred into the MediaPlayer and it continues to play.

However this solution has one major flaw: during the transfer of newly downloaded audio the MediaPlayer has to be paused, therefore, the music was interrupted at regular intervals of 20 seconds. This means it is of limited use. If you have conquered this problem yourself in a better way, please leave a comment; we’d be interested to hear about it.