多线程下载网络歌曲&播放歌曲&并用seekbar调节进度&显示歌曲两边的时间
这里先给一个处理时间格式的代码:
/**
* 时间的处理
*
* @param time
* @return
*/
public static String getTimeFromInt(int time) {
if (time <= 0) {
return "0:00";
}
int secondnd = (time / 1000) / 60;
int million = (time / 1000) % 60;
String f = String.valueOf(secondnd);
String m = million >= 10 ? String.valueOf(million) : "0"
+ String.valueOf(million);
return f + ":" + m;
}
下面是:
滑动条控制代码:
bar = (SeekBar) findViewById(R.id.seekBar);
bar.setOnSeekBarChangeListener(this);
int progress;
@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
// TODO Auto-generated method stub
System.out.println("目前位置:" + arg1);
progress = arg1;
// player.seekTo(progress);
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
player.seekTo(progress);
}