MediaPlayer play audio in background and play next one

前端 未结 2 1486
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 01:45

I use below code to play audio in background:

String[] Path = new String[] {path1, path2, ...};
mMediaPlayer.setDataSource(Path[i]);
mMediaPlayer.prepare();
         


        
2条回答
  •  甜味超标
    2021-01-14 02:06

    You need to set an OnCompletionListener to your MediaPlayer, in the listener set the source to path2, prepare and play. http://developer.android.com/reference/android/media/MediaPlayer.OnCompletionListener.html

提交回复
热议问题