From 22847c6c921274e87663d513f7de4ac822fe4f54 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 26 Sep 2021 20:50:24 +0200 Subject: [PATCH] Fixed progress bar not completing after video end --- .../org/schabi/newpipe/player/Player.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 5ad855e78..d3a2d1aa4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -1596,10 +1596,7 @@ public final class Player implements setVideoDurationToControls(duration); } if (currentState != STATE_PAUSED) { - if (currentState != STATE_PAUSED_SEEK) { - binding.playbackSeekBar.setProgress(currentProgress); - } - binding.playbackCurrentTime.setText(getTimeString(currentProgress)); + updatePlayBackElementsCurrentDuration(currentProgress); } if (simpleExoPlayer.isLoading() || bufferPercent > 90) { binding.playbackSeekBar.setSecondaryProgress( @@ -2253,6 +2250,9 @@ public final class Player implements stopProgressLoop(); } + // When a (short) video ends the elements have to display the correct values + updatePlayBackElementsCurrentDuration(binding.playbackSeekBar.getMax()); + showControls(500); animate(binding.currentDisplaySeek, false, 200, AnimationType.SCALE_AND_ALPHA); binding.loadingPanel.setVisibility(View.GONE); @@ -2595,6 +2595,18 @@ public final class Player implements //////////////////////////////////////////////////////////////////////////*/ //region Playback position and seek + /** + * Sets the current duration into the corresponding elements. + * @param currentProgress + */ + private void updatePlayBackElementsCurrentDuration(final int currentProgress) { + // Don't set seekbar progress while user is seeking + if (currentState != STATE_PAUSED_SEEK) { + binding.playbackSeekBar.setProgress(currentProgress); + } + binding.playbackCurrentTime.setText(getTimeString(currentProgress)); + } + @Override // own playback listener (this is a getter) public boolean isApproachingPlaybackEdge(final long timeToEndMillis) { // If live, then not near playback edge