Reputation: 135
I need to create only one media player object Mediaplayer mp = new Mediaplayer();
Using this I need to play multiple audio files one after the other for that i am using handler
and getting the duration.
If i create multiple media player objects it shows error(1, -17)
I also need to display images related to audio files.
Upvotes: 3
Views: 6254
Reputation: 4245
Implement the OnCompletionListener
and register it with your MediaPlayer
instance.
After the media has been played out it will call this callback method onCompletion
void onCompletion(MediaPlayer mp){
//Here you stop it.
mp.stop();
//Reset the data source path to the new file
mp.setDataSource(<uri>);
mp.prepare(); // or mp.prepareAsync();
// start the mediaplayer after the prepare has completed.
}
Release the mediaplayer instance once you are done playing all the files.
Upvotes: 0
Reputation: 768
Did you rule out SoundPool?
http://developer.android.com/reference/android/media/SoundPool.html
It typically good for short audio clips.
Upvotes: 1