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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…