문제

I need to play let's say 10 songs (1-10) serially. After one is played and finished, the next one starts, etc. What I have in mind is:

For (int i=0; i<10; i++) {
    mp = new MediaPlayer();
    mp.setDataSource(/* something given i */);
    mp.prepare();
    mp.start();
}

But won't that cause just one song to be played only? What could I do to make a row of them? Thanks a lot

도움이 되었습니까?

해결책

you can use mp.setOnCompletionListener for reading when a song is finished. See example below:

        mp.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            //code for starting next song..
        }

        });
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top