Android第三次作业
1.界面截图

2.关键代码
2.1设置音乐播放器的播放进度
private static SeekBar sb;
private static TextView tv_progress;
private static TextView tv_total;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_progress = (TextView) findViewById(R.id.tv_progress);
tv_total = (TextView) findViewById(R.id.tv_total);
2.2添加接口的控制类
class MusicControl extends Binder implements MusicInterface {
@Override
public void play() {
MusicService.this.play();
}
@Override
public void pausePlay() {
MusicService.this.pausePlay();
}
@Override
public void continuePlay() {
MusicService.this.continuePlay();
}
@Override
public void seekTo(int progress) {
MusicService.this.seekTo(progress);
}
}
2.3播放
public void play() {
try {
if(player == null)
{
player = new MediaPlayer();
}
2.4暂停
public void pausePlay() {
player.pause();
}
上一首及下一首功能暂未实现
3.代码链接: https://git.coding.net/mql1234/music.git

浙公网安备 33010602011771号