Skip to content

Commit

Permalink
Set KeyProgressIncrement manually
Browse files Browse the repository at this point in the history
* Set ``KeyProgressIncrement`` manually to the value of the seek duration in the settings so that it works when using the DPad
* consolidated code inside a new method to avoid duplication
  • Loading branch information
litetex committed Aug 26, 2021
1 parent bbcfdf2 commit c6ead35
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,7 @@ private void onUpdateProgress(final int currentProgress,
}

if (duration != binding.playbackSeekBar.getMax()) {
binding.playbackEndTime.setText(getTimeString(duration));
binding.playbackSeekBar.setMax(duration);
setVideoDurationToControls(duration);
}
if (currentState != STATE_PAUSED) {
if (currentState != STATE_PAUSED_SEEK) {
Expand Down Expand Up @@ -2073,8 +2072,8 @@ private void onPrepared(final boolean playWhenReady) {
Log.d(TAG, "onPrepared() called with: playWhenReady = [" + playWhenReady + "]");
}

binding.playbackSeekBar.setMax((int) simpleExoPlayer.getDuration());
binding.playbackEndTime.setText(getTimeString((int) simpleExoPlayer.getDuration()));
setVideoDurationToControls((int) simpleExoPlayer.getDuration());

binding.playbackSpeed.setText(formatSpeed(getPlaybackSpeed()));

if (playWhenReady) {
Expand Down Expand Up @@ -2716,6 +2715,20 @@ public void seekToDefault() {
simpleExoPlayer.seekToDefaultPosition();
}
}

/**
* Sets the video duration time into all control components (e.g. seekbar).
* @param duration
*/
private void setVideoDurationToControls(final int duration) {
binding.playbackEndTime.setText(getTimeString(duration));

binding.playbackSeekBar.setMax(duration);
// This is important for Android TVs otherwise it would apply the default from
// setMax/Min methods which is (max - min) / 20
binding.playbackSeekBar.setKeyProgressIncrement(
PlayerHelper.retrieveSeekDurationFromPreferences(this));
}
//endregion


Expand Down

0 comments on commit c6ead35

Please sign in to comment.