0

Creating music player related application,In raw folder having 5 mp3 files.want to play continuously and individually ,

else if (theText == song3) {

        mediaPlayer = MediaPlayer.create(this, R.raw.hiii);
    } else if (theText == song4) {

        mediaPlayer = MediaPlayer.create(this, R.raw.hiiii);
    }

This is how i am playing individual songs but how to play 5 songs continuously.Help me.

Community
  • 1
  • 1

1 Answers1

0

1.make an array of id if songs in raw folder.

  int arr[]={R.id.hiii,R.id.Hiiii,...........}

2.use this array in your code

  mediaPlayer=MediaPlayer.create(this, arr[i]);

3.implement setOnCompletionListener(Context); to start another song after one is over and loop it

Shakeeb Ayaz
  • 6,200
  • 6
  • 45
  • 64