我从本地获取mp3文件列表(作为一个ArrayList(Path)),逐个选择,但是如果完成移动到下一个并且如果完成所有列表循环,我无法让它们逐个播放再次。有什么帮助吗?
答案 0 :(得分:0)
我解决了问题thansk:http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-i
当然我做了一点修改,比如:
private void playSong() {
try {
mp.reset();
mp.setDataSource(playlist.get(currentPosition));
mp.prepare();
mp.start();
// Setup listener so next song starts automatically
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer arg0) {
nextSong();
}
});
} catch (IOException e) {
Log.v(getString(R.string.app_name), e.getMessage());
}
}
private void nextSong() {
if (++currentPosition >= playlist.size()) {
// Last song, just reset currentPosition
currentPosition = 0;
} else {
// Play next song
playSong(/*MEDIA_PATH + playlist.get(currentPosition)*/);
}
}