From 30ce906f724f6508dbe976d337690bc880e73b2f Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Fri, 21 Jan 2022 21:25:25 +0100 Subject: [PATCH] Apply seek conditions based on direction * When rewinding: Check if <0,5s * When fast-forwarding: Check if player has completed or the current playback has ended This allows rewinding on the endscreen --- .../org/schabi/newpipe/player/Player.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 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 431b4bb98..c7bc3db3a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -603,17 +603,25 @@ public final class Player implements public FastSeekDirection getFastSeekDirection( @NonNull 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 (invalidSeekConditions()) { + if (exoPlayerIsNull()) { + // Abort seeking playerGestureListener.endMultiDoubleTap(); return FastSeekDirection.NONE; } - if (portion == DisplayPortion.LEFT - // Small puffer to eliminate infinite rewind seeking - && simpleExoPlayer.getCurrentPosition() > 500L) { + if (portion == DisplayPortion.LEFT) { + // Check if we can rewind + // Small puffer to eliminate infinite rewind seeking + if (simpleExoPlayer.getCurrentPosition() < 500L) { + return FastSeekDirection.NONE; + } return FastSeekDirection.BACKWARD; } else if (portion == DisplayPortion.RIGHT) { + // Check if the can fast-forward + if (currentState == STATE_COMPLETED + || simpleExoPlayer.getCurrentPosition() + >= simpleExoPlayer.getDuration()) { + return FastSeekDirection.NONE; + } return FastSeekDirection.FORWARD; } /* portion == DisplayPortion.MIDDLE */ @@ -629,14 +637,6 @@ public final class Player implements fastRewind(); } } - - private boolean invalidSeekConditions() { - return exoPlayerIsNull() - || simpleExoPlayer.getPlaybackState() - == com.google.android.exoplayer2.Player.STATE_ENDED - || simpleExoPlayer.getCurrentPosition() >= simpleExoPlayer.getDuration() - || currentState == STATE_COMPLETED; - } }); playerGestureListener.doubleTapControls(binding.fastSeekOverlay); }