Android SeekBar to control MediaPlayer progress

前端 未结 6 1897
情话喂你
情话喂你 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:16

    Try this code in onCreate() method and run the project.I hope this is working.

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                mediaPlayer.seekTo(i);
            }
    
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
    
            }
    
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
    
            }
        });
    

提交回复
热议问题