Skip to content

Commit 30ce906

Browse files
committed
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
1 parent 1c20eab commit 30ce906

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -603,17 +603,25 @@ public void onDoubleTapEnd() {
603603
public FastSeekDirection getFastSeekDirection(
604604
@NonNull final DisplayPortion portion
605605
) {
606-
// Null indicates an invalid area or condition e.g. the middle portion
607-
// or video start or end was reached during double tap seeking
608-
if (invalidSeekConditions()) {
606+
if (exoPlayerIsNull()) {
607+
// Abort seeking
609608
playerGestureListener.endMultiDoubleTap();
610609
return FastSeekDirection.NONE;
611610
}
612-
if (portion == DisplayPortion.LEFT
613-
// Small puffer to eliminate infinite rewind seeking
614-
&& simpleExoPlayer.getCurrentPosition() > 500L) {
611+
if (portion == DisplayPortion.LEFT) {
612+
// Check if we can rewind
613+
// Small puffer to eliminate infinite rewind seeking
614+
if (simpleExoPlayer.getCurrentPosition() < 500L) {
615+
return FastSeekDirection.NONE;
616+
}
615617
return FastSeekDirection.BACKWARD;
616618
} else if (portion == DisplayPortion.RIGHT) {
619+
// Check if the can fast-forward
620+
if (currentState == STATE_COMPLETED
621+
|| simpleExoPlayer.getCurrentPosition()
622+
>= simpleExoPlayer.getDuration()) {
623+
return FastSeekDirection.NONE;
624+
}
617625
return FastSeekDirection.FORWARD;
618626
}
619627
/* portion == DisplayPortion.MIDDLE */
@@ -629,14 +637,6 @@ public void seek(final boolean forward) {
629637
fastRewind();
630638
}
631639
}
632-
633-
private boolean invalidSeekConditions() {
634-
return exoPlayerIsNull()
635-
|| simpleExoPlayer.getPlaybackState()
636-
== com.google.android.exoplayer2.Player.STATE_ENDED
637-
|| simpleExoPlayer.getCurrentPosition() >= simpleExoPlayer.getDuration()
638-
|| currentState == STATE_COMPLETED;
639-
}
640640
});
641641
playerGestureListener.doubleTapControls(binding.fastSeekOverlay);
642642
}

0 commit comments

Comments
 (0)