From 9ded8388614440f0b0d0ddf8053f6b81c4f81ff7 Mon Sep 17 00:00:00 2001 From: vkay94 Date: Sun, 22 Nov 2020 21:48:33 +0100 Subject: [PATCH] SeekOverlay: Fix forward issue when current progress is at position 0 --- .../newpipe/player/VideoPlayerImpl.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 4f818d04bcf..c7e6ac32b61 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -468,7 +468,8 @@ private void setupPlayerSeekOverlay() { @Override public void onPrepare() { - if (checkCorrectConditions()) { + if (getPlayer().getPlaybackState() == Player.STATE_IDLE + || getPlayer().getPlaybackState() == Player.STATE_ENDED) { gestureListener.endMultiDoubleTap(); return; } @@ -502,12 +503,9 @@ public void onAnimationEnd() { public Boolean shouldFastForward(@NotNull final DisplayPortion portion) { // Null indicates an invalid area or condition e.g. the middle portion // or video start or end was reached during double tap seeking - if (checkCorrectConditions()) { - return null; - } - if (portion == DisplayPortion.LEFT) { + if (portion == DisplayPortion.LEFT && checkRewindCondition()) { return false; - } else if (portion == DisplayPortion.RIGHT) { + } else if (portion == DisplayPortion.RIGHT && checkForwardCondition()) { return true; } else /* portion == DisplayPortion.MIDDLE */ { return null; @@ -524,12 +522,17 @@ public void seek(final boolean forward) { } } - private boolean checkCorrectConditions() { - return getPlayer().getCurrentPosition() == getPlayer().getDuration() - // Add puffer of a half second, so that direct rewinding is not possible - || getPlayer().getCurrentPosition() <= 500L - || getPlayer().getPlaybackState() == Player.STATE_ENDED - || getPlayer().getPlaybackState() == Player.STATE_IDLE; + private boolean checkRewindCondition() { + // Add puffer of a half second, so that direct rewinding is not possible + return getPlayer().getCurrentPosition() > 500L + && getPlayer().getPlaybackState() != Player.STATE_IDLE + && getPlayer().getPlaybackState() != Player.STATE_ENDED; + } + + private boolean checkForwardCondition() { + return getPlayer().getCurrentPosition() < getPlayer().getDuration() + && getPlayer().getPlaybackState() != Player.STATE_IDLE + && getPlayer().getPlaybackState() != Player.STATE_ENDED; } }); gestureListener.doubleTapControls(seekOverlay);