开发者

Android media streaming/incremental download question

I'm currently developing an application that uses Android's MediaPlayer setDataSource(url) method to play SHOUTCast streams. I'm in the process of switching the current code from using the setDataSource(url) method to setDataSource(file) where file in an incremental download of the file I'm steaming. Similar to this tutorial:

http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

My question is this:

This method will work fine for files of a fixed length because once the stream has completed the file can be delete (i.e I stream an mp3 and when the song is finished I delete the old temp file before creating a new one). However, if I'm playing a SHOUT开发者_如何学编程cast stream which never technically "ends" how do I keep the phone storage from filling up due to the temp file size continually increasing?


I'm not experienced in streaming this way with the MediaPlayer, but I imagine this solution may work:

Use two files. When one reaches a size threshold, begin downloading the stream to both files. When there is enough buffer in the second file, begin streaming from the second file and delete the first. Swap back and forth for as long as you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜