fixed (?) possible duplicate segment skips

This commit is contained in:
polymorphicshade 2021-03-05 17:52:34 -07:00
parent d60574581b
commit 6e3e5e8114
2 changed files with 16 additions and 1 deletions

View file

@ -46,6 +46,7 @@ public class LocalPlayer implements EventListener {
private VideoSegment[] videoSegments; private VideoSegment[] videoSegments;
private LocalPlayerListener listener; private LocalPlayerListener listener;
private int lastCurrentProgress = -1; private int lastCurrentProgress = -1;
private int lastSkipTarget = -1;
public LocalPlayer(final Context context) { public LocalPlayer(final Context context) {
this.context = context; this.context = context;
@ -248,6 +249,7 @@ public class LocalPlayer implements EventListener {
final VideoSegment segment = getSkippableSegment(currentProgress); final VideoSegment segment = getSkippableSegment(currentProgress);
if (segment == null) { if (segment == null) {
lastSkipTarget = -1;
return; return;
} }
@ -259,6 +261,12 @@ public class LocalPlayer implements EventListener {
skipTarget = 0; skipTarget = 0;
} }
if (lastSkipTarget == skipTarget) {
return;
}
lastSkipTarget = skipTarget;
// temporarily force EXACT seek parameters to prevent infinite skip looping // temporarily force EXACT seek parameters to prevent infinite skip looping
final SeekParameters seekParams = simpleExoPlayer.getSeekParameters(); final SeekParameters seekParams = simpleExoPlayer.getSeekParameters();
simpleExoPlayer.setSeekParameters(SeekParameters.EXACT); simpleExoPlayer.setSeekParameters(SeekParameters.EXACT);

View file

@ -383,7 +383,7 @@ public final class Player implements
// SponsorBlock // SponsorBlock
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
private SponsorBlockMode sponsorBlockMode = SponsorBlockMode.DISABLED; private SponsorBlockMode sponsorBlockMode = SponsorBlockMode.DISABLED;
private int lastSkipTarget = -1;
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -1563,6 +1563,7 @@ public final class Player implements
if (sponsorBlockMode == SponsorBlockMode.ENABLED) { if (sponsorBlockMode == SponsorBlockMode.ENABLED) {
final VideoSegment segment = getSkippableSegment(currentProgress); final VideoSegment segment = getSkippableSegment(currentProgress);
if (segment == null) { if (segment == null) {
lastSkipTarget = -1;
return; return;
} }
@ -1574,6 +1575,12 @@ public final class Player implements
skipTarget = 0; skipTarget = 0;
} }
if (lastSkipTarget == skipTarget) {
return;
}
lastSkipTarget = skipTarget;
// temporarily force EXACT seek parameters to prevent infinite skip looping // temporarily force EXACT seek parameters to prevent infinite skip looping
final SeekParameters seekParams = simpleExoPlayer.getSeekParameters(); final SeekParameters seekParams = simpleExoPlayer.getSeekParameters();
simpleExoPlayer.setSeekParameters(SeekParameters.EXACT); simpleExoPlayer.setSeekParameters(SeekParameters.EXACT);