From c118c77c14fadda06ab77bef54c0ed494178b00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Fri, 26 Apr 2024 13:40:00 +0200 Subject: [PATCH] SponsorBlock jump to end instead of pausing When the time stamp for the last segment is greater the duration currently the video pauses. This interferes with PR #646. Now instead of pausing we jump to the duration (end time) of the video instead. --- Model/Player/PlayerSponsorBlock.swift | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Model/Player/PlayerSponsorBlock.swift b/Model/Player/PlayerSponsorBlock.swift index 4aca4ecb..627e68fb 100644 --- a/Model/Player/PlayerSponsorBlock.swift +++ b/Model/Player/PlayerSponsorBlock.swift @@ -44,22 +44,6 @@ extension PlayerModel { } private func skip(_ segment: Segment, at time: CMTime) { - if let duration = playerItemDuration, segment.endTime.seconds >= duration.seconds - 3 { - logger.error("segment end time is: \(segment.end) when player item duration is: \(duration.seconds)") - - DispatchQueue.main.async { [weak self] in - guard let self else { - return - } - - self.pause() - - self.backend.eofPlaybackModeAction() - } - - return - } - backend.seek(to: segment.endTime, seekType: .segmentSkip(segment.category)) DispatchQueue.main.async { [weak self] in @@ -69,6 +53,14 @@ extension PlayerModel { self?.segmentRestorationTime = time } logger.info("SponsorBlock skipping to: \(segment.end)") + + if let duration = playerItemDuration, segment.endTime.seconds >= duration.seconds - 3 { + logger.error("Segment end time is: \(segment.end) when player item duration is: \(duration.seconds)") + + DispatchQueue.main.async { [weak self] in + self?.backend.eofPlaybackModeAction() + } + } } private func shouldSkip(_ segment: Segment, at time: CMTime) -> Bool {