Skip to content

Commit

Permalink
Merge pull request #72 from mikooomich/dev
Browse files Browse the repository at this point in the history
Fix non-graced rewinding
  • Loading branch information
polymorphicshade authored May 17, 2024
2 parents 3d579ae + 02deb69 commit 732ae9c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,10 @@ private void triggerCheckForSponsorBlockSegments(final int currentProgress,
seekTo(skipTarget);

simpleExoPlayer.setSeekParameters(seekParams);
lastSegment = sponsorBlockSegment;
if (!isRewind || isGracedRewind) {
// DO NOT TRACK for non-graced rewinds to work, BUT always track for graced
lastSegment = sponsorBlockSegment;
}

if (isUnSkip) {
return;
Expand Down Expand Up @@ -1881,6 +1884,7 @@ public void fastRewind() {
return;
}

destroyUnskipVars(); // destroy, else rewind into segment won't skip
triggerProgressUpdate(true);
}
//endregion
Expand Down Expand Up @@ -2502,12 +2506,7 @@ public Optional<SponsorBlockSegment> getSkippableSponsorBlockSegment(final int p
&& progress > lastSegment.endTime + UNSKIP_WINDOW_MILLIS) {
// un-skip window is over
hideUnskipButtons();
lastSegment = null;
autoSkipGracePeriod = false;

if (DEBUG) {
Log.d("SPONSOR_BLOCK", "Destroyed last segment variables (UNSKIP)");
}
destroyUnskipVars();
} else if (lastSegment != null
&& progress < lastSegment.endTime + UNSKIP_WINDOW_MILLIS
&& progress >= lastSegment.startTime) {
Expand All @@ -2528,6 +2527,15 @@ private void hideUnskipButtons() {
UIs.call(PlayerUi::hideAutoUnskip);
}

private void destroyUnskipVars() {
lastSegment = null;
autoSkipGracePeriod = false;

if (DEBUG) {
Log.d("SPONSOR_BLOCK", "Destroyed last segment variables (UNSKIP)");
}
}

private SponsorBlockSecondaryMode getSecondaryMode(final SponsorBlockSegment segment) {
if (segment == null) {
return SponsorBlockSecondaryMode.DISABLED;
Expand Down

0 comments on commit 732ae9c

Please sign in to comment.