Streaming to the Android MediaPlayer

Posted by Rob Szumlakowski on Stack Overflow See other posts from Stack Overflow or by Rob Szumlakowski
Published on 2010-03-24T20:13:02Z Indexed on 2010/03/24 20:33 UTC
Read the original article Hit count: 840

Filed under:
|
|
|

Hi. I'm trying to write a light-weight HTTP server in my app to feed dynamically generated MP3 data to the built-in Android MediaPlayer. I am not permitted to store my content on the SD card.

My input data is essentially of an infinite length. I tell MediaPlayer that its data source should basically be something like "http://localhost/myfile.mp3". I've a simple server set up that waits for MediaPlayer to make this request. However, MediaPlayer isn't very cooperative. At first, it makes an HTTP GET and tries to grab the whole file. It times out if we try and simply dump data into the socket so we tried using the HTTP Range header to write data in chunks. MediaPlayer doesn't like this and doesn't keep requesting the subsequent chunks.

Has anyone had any success streaming data directly into MediaPlayer? Do I need to implement an RTSP or Shoutcast server instead? Am I simply missing a critical HTTP header? What strategy should I use here?

Rob Szumlakowski

© Stack Overflow or respective owner

Related posts about android

Related posts about mediaplayer