我目前正在播放一首歌,但我需要再播放两首。第一局结束后,第二局应自动开始播放。当第二首结束时,第三首歌曲应开始播放。
这是我当前用来播放第一首歌曲的代码。
if(mState == STATE_PAUSED) {
mPlayer.start();
mState = STATE_STARTED;
} else if(mState != STATE_STARTED && mState != STATE_PREPARING) {
mPlayer.reset();
mState = STATE_IDLE;
try {
Uri songUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.one);
// Set our data source to transition to STATE_INITIALIZED.
mPlayer.setDataSource(this, songUri);
mState = STATE_INITIALIZED;
} catch (IOException e) {
e.printStackTrace();
}
// Make sure we initialized properly.
if (mState == STATE_INITIALIZED) {
mPlayer.prepareAsync();
mState = STATE_PREPARING;
}
Notification ongoing = buildNotification();
startForeground(NOTIFICATION_ID, ongoing);
}
如何使用Uri添加另外两首歌曲,并且行为如前所述。预先谢谢你。