From 02deb69e25bed1809b46ad1454fe142dfd3d35ca Mon Sep 17 00:00:00 2001 From: mikooomich Date: Sun, 12 May 2024 21:42:00 -0400 Subject: [PATCH] Destroy unskip tracking variables when non-graced rewinding * Also add back destroyUnskipVars() helper --- .../org/schabi/newpipe/player/Player.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 4f0d2490d..60f6612f7 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -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; @@ -1881,6 +1884,7 @@ public void fastRewind() { return; } + destroyUnskipVars(); // destroy, else rewind into segment won't skip triggerProgressUpdate(true); } //endregion @@ -2502,12 +2506,7 @@ public Optional 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) { @@ -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;