fix(YouTube - SponsorBlock): Do not auto skip end segments more than once if using a slow playback speed

This commit is contained in:
LisoUseInAIKyrios 2023-12-26 00:46:20 +04:00
parent 5ae2312804
commit 88b3ca4992

View File

@ -510,16 +510,19 @@ public class SegmentPlaybackController {
SponsorBlockViewController.hideSkipHighlightButton(); SponsorBlockViewController.hideSkipHighlightButton();
SponsorBlockViewController.hideSkipSegmentButton(); SponsorBlockViewController.hideSkipSegmentButton();
final long now = System.currentTimeMillis();
if (lastSegmentSkipped == segmentToSkip) {
// If trying to seek to end of the video, YouTube can seek just before of the actual end. // If trying to seek to end of the video, YouTube can seek just before of the actual end.
// (especially if the video does not end on a whole second boundary). // (especially if the video does not end on a whole second boundary).
// This causes additional segment skip attempts, even though it cannot seek any closer to the desired time. // This causes additional segment skip attempts, even though it cannot seek any closer to the desired time.
// Check for and ignore repeated skip attempts of the same segment over a small time period. // Check for and ignore repeated skip attempts of the same segment over a small time period.
final long now = System.currentTimeMillis(); final long minTimeBetweenSkippingSameSegment = Math.max(500,
final long minimumMillisecondsBetweenSkippingSameSegment = 500; (long) (500 / VideoInformation.getPlaybackSpeed()));
if ((lastSegmentSkipped == segmentToSkip) && (now - lastSegmentSkippedTime < minimumMillisecondsBetweenSkippingSameSegment)) { if (now - lastSegmentSkippedTime < minTimeBetweenSkippingSameSegment) {
LogHelper.printDebug(() -> "Ignoring skip segment request (already skipped as close as possible): " + segmentToSkip); LogHelper.printDebug(() -> "Ignoring skip segment request (already skipped as close as possible): " + segmentToSkip);
return; return;
} }
}
LogHelper.printDebug(() -> "Skipping segment: " + segmentToSkip); LogHelper.printDebug(() -> "Skipping segment: " + segmentToSkip);
lastSegmentSkipped = segmentToSkip; lastSegmentSkipped = segmentToSkip;