I am developing an application where i need to retrieve multiple audio files from server and display them in one activity.If there are two audio files on server then dynamically two audio players should be displayed in my activity, if there are 5 audio files then 5 audio players should come with respective audio files. Retrieving one audio file and playing it, is easy. What i need is to retrieve more than 1 audio files and playing them in separate players. please help?
I am developing an application where i need to retrieve multiple audio files from
Share
You should use MediaPlayer class in order to stream your audio from a remote server.
You can set the streaming url doing this:
If you want to have multiple independent streaming players on the same activity then you have to instantiate dinamically different mediaplayers. Something like that
Having multiple mediaplayer for multiple songs is the simplest solution but also the less efficent. If you want a more efficent solution you can instatiate a single mediaplayer, and save the state of the previous song when you want to play at runtime the next one.
You can find some reference here: http://developer.android.com/reference/android/media/MediaPlayer.html