2 baidu 37299572 baidu_37299572 于 2017.01.17 14:49 提问

拖动seekbar后获取的seekbar.getProgress()值有一些误差如何解决

private void setSeerBar() {
mMax = mediaPlayer.getDuration();
seekbar.setMax(mMax);
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(final SeekBar seekBar, int progress, boolean fromUser) {
currentProgress_seek = seekbar.getProgress();
currentProgress_media = mediaPlayer.getCurrentPosition();

    long timelong = currentProgress_seek / 1000;
    hour_ = timelong / 60 / 60;
    minute_ = (timelong / 60) % 60;
    second_ = timelong % 60;
    Log.e("nowtime", "currenttime:" + hour_ + ":" + minute_ + ":" + second_);


}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {


}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    if (mediaPlayer != null) {
        mMax = mediaPlayer.getDuration();
        mediaPlayer.seekTo(currentProgress_seek);
        currentProgress_media = mediaPlayer.getCurrentPosition();
        currentProgress_seek = seekbar.getProgress();
        long timelong = currentProgress_media / 1000;
        hour_ = timelong / 60 / 60;
        minute_ = (timelong / 60) % 60;
        second_ = timelong % 60;
        Log.e("nowtime", "stoptime:" + hour_ + ":" + minute_ + ":" + second_);
        Log.e("SeekBarState", "stopprovess" + seekbar.getProgress());
        Message message = new Message();
        handler.sendEmptyMessage(message.what);
    }

}

});

}

然后打印出来的结果是: currenttime:0:49:14
01-11 11:55:54.687 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:49:15
01-11 11:55:55.691 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:49:16
01-11 11:55:56.120 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:42:15
01-11 11:55:56.213 10778-10778/com.example.bmvod.film E/nowtime: stoptime:0:42:15
01-11 11:55:56.688 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:42:10
01-11 11:55:57.688 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:42:11
01-11 11:55:58.687 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:42:12
01-11 11:55:59.689 10778-10778/com.example.bmvod.film E/nowtime: currenttime:0:42:13
这样的,,
停止的时间是42分15秒,然后下一个打印应该是42分16秒,但是打印结果是42分10秒 这个误差是如何产生的?怎么解决呢?。。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!