Skip to content

Commit

Permalink
SeekOverlay: Fix forward issue when current progress is at position 0
Browse files Browse the repository at this point in the history
  • Loading branch information
vkay94 committed Dec 11, 2020
1 parent 5a52de1 commit 9ded838
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 9ded838

Please sign in to comment.