What I want is to save mp3 files on Firebase Storage and then stream it to an Android device. All the tutorials on Firebase discuss about the image file upload and download.
If there are any other cloud that is more easy than Firebase to store and stream audio for android, then please suggest.
Firebase provide StreamDownloadTask as Mike has suggested, for getting InputStream but unfortunately MediaPlayer doesn't accept a direct stream. Now we have 2 options if we strictly like to continue with InputStream, as far as I know -
a. Write a stream in the temporary file and pass it to the media player. Personally, I don't recommend this approach. It includes unnecessary data writing and you also have to maintain synchronization between streamed data, file writing and media play.
b. Create StreamProxy server as npr news App doing. You can find the source code of App here.
Simple way to play Music file from Firebase is to first fetch the download URL by using storage reference and pass that URL to media player as a dataSource. Below is the code snippet -