主要功能介紹git
實現音樂暫停,播放,下一首,上一首;app
程序運行截圖.net
程序運行動態視頻視頻
核心代碼解析blog
功能鍵的實現get
public void onClick(View v) {
switch(v.getId()){
case R.id.song1:
if(!mediaPlayer.isPlaying()){
initMediaPlayer(1);
mediaPlayer.start();
}
case R.id.song2:
if(!mediaPlayer.isPlaying()){
initMediaPlayer(1);
mediaPlayer.start();
}
case R.id.song3:
if(!mediaPlayer.isPlaying()){
initMediaPlayer(2);
mediaPlayer.start();
}
case R.id.start:
if(!mediaPlayer.isPlaying()){
mediaPlayer.start();//開始
}
break;
case R.id.pause:
if(mediaPlayer.isPlaying()){
mediaPlayer.pause();//暫停
}
break;
case R.id.last:
if(mediaPlayer.isPlaying()){
n--;
initMediaPlayer(n);
mediaPlayer.start();//上一曲
}
break;
case R.id.next:
if(mediaPlayer.isPlaying()){
n++;
initMediaPlayer(n);
mediaPlayer.start();//下一曲
}
break;
default:
break;
}
}
項目地址it
https://qcloud.coding.net/u/love999love/p/AndroidMusic/gitio
APP下載連接ast
https://dev.tencent.com/u/love999love/p/AndroidMusic/git/tree/master/MyApplication1/app/releaseclass