1500802083

实现的功能

  播放,暂停,停止,上一首,下一首。

  以列表显示

 主要代码:

此部分为实现上一首下一首按钮功能的代码

class myListener implements View.OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button2:
button2.setEnabled(false);
button2.setBackgroundColor(Color.GRAY);
if(one<1)
{
String p = list.get(current).path;
play(p);
one++;
}
else {
play1();
}
break;
case R.id.button3:
pause();
break;
case R.id.button1:
if (current > 0) {
current = current - 1;
String p1 = list.get(current).path;
play(p1);
} else {
current = list.size() - 1;
String p1 = list.get(current).path;
play(p1);
}
break;
case R.id.button4:
if (current + 1 < list.size()) {
current = current + 1;
String p2 = list.get(current).path;
play(p2);
} else {
current = 0;
String p2 = list.get(current).path;
play(p2);
}
break;
default:
break;
}
}
}

实现上一首下一首的切换功能

 

 



代码:(https://coding.net/u/keroro85/p/music/git/tree/master
app:https://coding.net/s/8d4eb981-5537-415e-a3de-077c7c95ba6d

运行视频:https://coding.net/s/d9cc1fbc-eb8f-4626-bd68-59a615f8cbfc

posted @ 2018-12-11 22:40  尤里复裂人  阅读(145)  评论(0编辑  收藏  举报