How to cache into disk audio streamed into MediaPlayer? I’d like to use cached audio instead of downloading it each time. Unfortunately setDataSource even do not accepts InputStream, so I don’t know solution.. My code:
mediaPlayer.setDataSource(context, Uri.parse(/* file url */));
mediaPlayer.prepare();
mediaPlayer.start();
You can download it to the SDcard (or anywhere) and then play it back using the
public void setDataSource (String path)method of MediaPlayeryou may have to tweak the path to get it correct.
http://developer.android.com/reference/android/media/MediaPlayer.html#setDataSource(java.lang.String)