Android SeekBar to control MediaPlayer progress

前端 未结 6 1901
情话喂你
情话喂你 2020-12-24 14:43

I have a SeekBar, it displays correctly MediaPlayer progress. However, I have troubles with seeking - if I seek scroll box somewhere it just return

6条回答
  •  一生所求
    2020-12-24 15:23

    if you want to resume media player to specific position from seekbar change progress, I recommend you to do that in onStopTrackingTouch() method. that method will notify that the user has finished a touch gesture, then set media player position from seekbar's current position.

     @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    
    }
    
    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    
    }
    
    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        mediaPlayer.seekTo(seekBar.getProgress());
    }
    

提交回复
热议问题