I'm using Android's MediaPlayer to play MP3 files that are simultaneously downloaded from the internet using the DownloadManager. I'm aware of the MediaPlayer's capability to stream directly, but I don't want to use that:
The obvious advantage you get by downloading and simultaneously streaming from file is that this way, the file gets stored and is available locally afterwards.
- This works in principle - the
MediaPlayerstarts to play the file even if it not fully downloaded. (BTW my problem is NOT that I can't getMediaPlayerto play.) - The problem is that when the
MediaPlayergets to the position where the download status just was when it started playing, it stops and callsonCompletion. (Clarification: Let's assume the file is 12% downloaded when I start playing. When the player gets to the position at 12%, it stops.) - Quick side note:
OnBufferingUpdateListener.onBufferingUpdate(...)is not called when something is appended to the MP3 file via theDownloadManager.
So the question is: How can I simultaneously download an audio file to the file system and play it? (Android 4+ suffices, if that makes a difference.)