There is a list of sound files:
static int[] sounds = {R.raw.cat1, R.raw.cat2, R.raw.cat3}; There is a file playback method :
private void meowPlay(int fileName) { mp = MediaPlayer.create(this, fileName); mp.setLooping(false); mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { public void onPrepared(MediaPlayer mp) { mp.start(); } }); mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mp) { mp.release(); } }); } By pressing the button , the following code is executed:
for (int i = 1; i <= 3; i++) { int rand = new Random().nextInt(2); meowPlay(sounds[rand]); } As a result, 3 audio files are played simultaneously . Can you please tell me how to make a sequential playback of these files?