Take the 2-minute tour ×

Is there a beautiful way to download an MP3 file via HTTP and cache it, playing it at the same time?

I tried to write downloaded bytes to a file and play that file using MediaPlayer. But when playing speed reaches downloading speed, playback stops. I don't think I'm thinking in a right direction. Writing into a file and reading it it at the same time seems to be quite strange, or am I wrong?

share|improve this question
Provide more information and what you have done? –  Dipak Keshariya Jul 3 '12 at 8:34
some discussion code.google.com/p/android/issues/detail?id=739 –  Niko Jul 3 '12 at 8:57
@Niko I've googled it already, they discussed about Android 1.0 and found nothing –  o2genum Jul 3 '12 at 9:07
Can you post the url from where you are trying to play audio? –  Nishant Shah Jul 10 '13 at 6:48
add comment

2 Answers

up vote 3 down vote accepted

But when playing speed reaches downloading speed, playback stops.

This is the key: you cannot play what you have not downloaded yet, no matter how you handle files, bytes etc. on the client side.

Most of applications that try to play "live" have buffer long enough to compensate for fluctuations of download speed. And if download speed is actually slower than playback speed (which is unusual for audio stream but possible) your goal may be not achievable at all - you may have to download whole song before playing it in order to ensure there will be no pauses in the playback.

share|improve this answer
add comment

I found something. Almost my way, but write/reading one file is avoided by copying files.

share|improve this answer
add comment

Your Answer


