Custom search bar for streaming video in android

How can we display a custom search bar for streaming video in android?

+4
source share
2 answers

Hi, you can use the code below to create a custom search bar to watch the video,

videoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { seekBar.setMax(videoView.getDuration()); seekBar.postDelayed(onEverySecond, 1000); } }); private Runnable onEverySecond=new Runnable() { @Override public void run() { if(seekBar != null) { seekBar.setProgress(videoView.getCurrentPosition()); } if(videoView.isPlaying()) { seekBar.postDelayed(onEverySecond, 1000); } } }; seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if(fromUser) { // this is when actually seekbar has been seeked to a new position videoView.seekTo(progress); } } }); 
+6
source

Just use the SeekBar class. Then you can use setProgress() and setSecondaryProgress() .

If you want to change the style, see this question: How to customize the look of SeekBar on Android?

0
source

All Articles