0

I'm new to android, so I'm a little stuck. I guess this is a standard feature of media players. I have about 10 music files in my raw folder. What I want to do is retrieve five of them and play them one after another, looping the entire series until the user clicks the stop button--essentially I want a continuous play feature for more than 1 file. Looping one file is easy. But how do I loop a series? Any help would be appreciated.

3 Answers3

0

create a counter for them and write call back method or run thread to when the one audio finished, start next and when counter reach to the end, reset it and play from start
if u need a sample code, post your code

Saeed-rz
  • 1,435
  • 1
  • 20
  • 38
0
mp.setOnCompletionListener(new OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
                playAnotherSong();
            }

            });

Do it this way.

Niraj Adhikari
  • 1,678
  • 2
  • 14
  • 28
0

Here, you can use this snippet to loop multiple audio files. Following code illustrates looping two files.., you can proceed similarly for even more files:

//create a media player
MediaPlayer mp1 = MediaPlayer.create(this, R.raw.audio1);
//another media player
MediaPlayer mp2 = MediaPlayer.create(this, R.raw.audio2);

//set next media player for mp2
mp2.setNextMediaPlayer(mp1);

//set next media player for mp1
mp1.setNextMediaPlayer(mp2);
//start first media player
mp1.start();
Akshay
  • 1
  • 1