Skip to content

Commit d716d44

Browse files
committed
SeekOverlay: Fix forward issue when current progress is at position 0
1 parent 690c6a7 commit d716d44

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ private void setupPlayerSeekOverlay() {
469469

470470
@Override
471471
public void onPrepare() {
472-
if (checkCorrectConditions()) {
472+
if (getPlayer().getPlaybackState() == Player.STATE_IDLE
473+
|| getPlayer().getPlaybackState() == Player.STATE_ENDED) {
473474
gestureListener.endMultiDoubleTap();
474475
return;
475476
}
@@ -503,12 +504,9 @@ public void onAnimationEnd() {
503504
public Boolean shouldFastForward(@NotNull final DisplayPortion portion) {
504505
// Null indicates an invalid area or condition e.g. the middle portion
505506
// or video start or end was reached during double tap seeking
506-
if (checkCorrectConditions()) {
507-
return null;
508-
}
509-
if (portion == DisplayPortion.LEFT) {
507+
if (portion == DisplayPortion.LEFT && checkRewindCondition()) {
510508
return false;
511-
} else if (portion == DisplayPortion.RIGHT) {
509+
} else if (portion == DisplayPortion.RIGHT && checkForwardCondition()) {
512510
return true;
513511
} else /* portion == DisplayPortion.MIDDLE */ {
514512
return null;
@@ -525,12 +523,17 @@ public void seek(final boolean forward) {
525523
}
526524
}
527525

528-
private boolean checkCorrectConditions() {
529-
return getPlayer().getCurrentPosition() == getPlayer().getDuration()
530-
// Add puffer of a half second, so that direct rewinding is not possible
531-
|| getPlayer().getCurrentPosition() <= 500L
532-
|| getPlayer().getPlaybackState() == Player.STATE_ENDED
533-
|| getPlayer().getPlaybackState() == Player.STATE_IDLE;
526+
private boolean checkRewindCondition() {
527+
// Add puffer of a half second, so that direct rewinding is not possible
528+
return getPlayer().getCurrentPosition() > 500L
529+
&& getPlayer().getPlaybackState() != Player.STATE_IDLE
530+
&& getPlayer().getPlaybackState() != Player.STATE_ENDED;
531+
}
532+
533+
private boolean checkForwardCondition() {
534+
return getPlayer().getCurrentPosition() < getPlayer().getDuration()
535+
&& getPlayer().getPlaybackState() != Player.STATE_IDLE
536+
&& getPlayer().getPlaybackState() != Player.STATE_ENDED;
534537
}
535538
});
536539
gestureListener.doubleTapControls(seekOverlay);

0 commit comments

Comments
 (0)