playb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
player = MediaPlayer.create(MainActivity.this, R.raw.song);
player.start();
playb.setClickable(false);
seeksong.setMax(player.getDuration());
new Thread(new SeekHandler()).start();
}
});
SeekHandler extends MainActivity implements Runnable{
@Override
public void run() {
while (player != null && player.getCurrentPosition() < player.getDuration()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return;
} catch (Exception e) {
return;
}
seeksong.setProgress(player.getCurrentPosition());
}
}
SeekBar没有更新到当前歌曲位置。请告诉我这样做的正确方法。如果有其他方法可供选择