From 6e3e5e811438ebeea569f9a93d4bfa51f438af86 Mon Sep 17 00:00:00 2001 From: polymorphicshade Date: Fri, 5 Mar 2021 17:52:34 -0700 Subject: [PATCH] fixed (?) possible duplicate segment skips --- .../main/java/org/schabi/newpipe/player/LocalPlayer.java | 8 ++++++++ app/src/main/java/org/schabi/newpipe/player/Player.java | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java b/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java index 7376493b6..f9881ccb7 100644 --- a/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/LocalPlayer.java @@ -46,6 +46,7 @@ public class LocalPlayer implements EventListener { private VideoSegment[] videoSegments; private LocalPlayerListener listener; private int lastCurrentProgress = -1; + private int lastSkipTarget = -1; public LocalPlayer(final Context context) { this.context = context; @@ -248,6 +249,7 @@ public class LocalPlayer implements EventListener { final VideoSegment segment = getSkippableSegment(currentProgress); if (segment == null) { + lastSkipTarget = -1; return; } @@ -259,6 +261,12 @@ public class LocalPlayer implements EventListener { skipTarget = 0; } + if (lastSkipTarget == skipTarget) { + return; + } + + lastSkipTarget = skipTarget; + // temporarily force EXACT seek parameters to prevent infinite skip looping final SeekParameters seekParams = simpleExoPlayer.getSeekParameters(); simpleExoPlayer.setSeekParameters(SeekParameters.EXACT); 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 8ad71684b..67c754812 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -383,7 +383,7 @@ public final class Player implements // SponsorBlock //////////////////////////////////////////////////////////////////////////*/ private SponsorBlockMode sponsorBlockMode = SponsorBlockMode.DISABLED; - + private int lastSkipTarget = -1; /*////////////////////////////////////////////////////////////////////////// @@ -1563,6 +1563,7 @@ public final class Player implements if (sponsorBlockMode == SponsorBlockMode.ENABLED) { final VideoSegment segment = getSkippableSegment(currentProgress); if (segment == null) { + lastSkipTarget = -1; return; } @@ -1574,6 +1575,12 @@ public final class Player implements skipTarget = 0; } + if (lastSkipTarget == skipTarget) { + return; + } + + lastSkipTarget = skipTarget; + // temporarily force EXACT seek parameters to prevent infinite skip looping final SeekParameters seekParams = simpleExoPlayer.getSeekParameters(); simpleExoPlayer.setSeekParameters(SeekParameters.EXACT);