I have multiple audio files in the assets directory of my application. When the user clicks a button I want to play those files in a certain order, one after the other. Ther
you are on the right way, don't need a lot of OnCompletionListener´s.
//define a variable to be used as index.
int audioindex = 0;
//Extract the files into an array
String[] files = null;
files = assetManager.list("audiofiles");
then in your OnCompletionListener.
mp.setOnCompletionListener(new OnCompletionListener(){
// @Override
public void onCompletion(MediaPlayer arg0) {
// File has ended, play the next one.
FunctionPlayFile(files[audioindex]);
audioindex+=1; //increment the index to get the next audiofile
}
});