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
This commit is contained in:
litetex 2022-01-21 21:25:25 +01:00
parent 1c20eabb48
commit 30ce906f72
1 changed files with 14 additions and 14 deletions

View File

@ -603,17 +603,25 @@ public final class Player implements
public FastSeekDirection getFastSeekDirection( public FastSeekDirection getFastSeekDirection(
@NonNull final DisplayPortion portion @NonNull final DisplayPortion portion
) { ) {
// Null indicates an invalid area or condition e.g. the middle portion if (exoPlayerIsNull()) {
// or video start or end was reached during double tap seeking // Abort seeking
if (invalidSeekConditions()) {
playerGestureListener.endMultiDoubleTap(); playerGestureListener.endMultiDoubleTap();
return FastSeekDirection.NONE; return FastSeekDirection.NONE;
} }
if (portion == DisplayPortion.LEFT if (portion == DisplayPortion.LEFT) {
// Small puffer to eliminate infinite rewind seeking // Check if we can rewind
&& simpleExoPlayer.getCurrentPosition() > 500L) { // Small puffer to eliminate infinite rewind seeking
if (simpleExoPlayer.getCurrentPosition() < 500L) {
return FastSeekDirection.NONE;
}
return FastSeekDirection.BACKWARD; return FastSeekDirection.BACKWARD;
} else if (portion == DisplayPortion.RIGHT) { } 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; return FastSeekDirection.FORWARD;
} }
/* portion == DisplayPortion.MIDDLE */ /* portion == DisplayPortion.MIDDLE */
@ -629,14 +637,6 @@ public final class Player implements
fastRewind(); 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); playerGestureListener.doubleTapControls(binding.fastSeekOverlay);
} }