一、界面截图
二、关键代码
上一首下一首
case R.id.next:
playMusic(++currentPosition % files.length);
break;
case R.id.precious:
if (currentPosition < 1) {
currentPosition += files.length;
}
playMusic(--currentPosition % files.length);
break;
播放音乐
private void playMusic(int position) {
try {
if (player != null) {
player.release();
}
player = new MediaPlayer();
player.setDataSource(files[position].getAbsolutePath());
player.prepare();
player.start();
((ImageView)findViewById(R.id.start)).setImageResource(R.drawable.start);
} catch (IOException e) {
e.printStackTrace();
}
}
三、coding链接
https://git.coding.net/aX_qhu/MusicPlayer.git
四、apk下载链接
五、视频演示