Skip to content

Commit

Permalink
Destroy unskip tracking variables when non-graced rewinding
Browse files Browse the repository at this point in the history
* Also add back destroyUnskipVars() helper
  • Loading branch information
mikooomich committed May 13, 2024
1 parent b25b1e2 commit 02deb69
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 02deb69

Please sign in to comment.