From f32247d1256b50f4a6010de971a7ac026467f407 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 17 Apr 2022 11:32:04 +0200 Subject: [PATCH] Throttle SponsorBlock seek --- Model/Player/Backends/MPVBackend.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index 7528bbf3..eba076c1 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -250,6 +250,8 @@ final class MPVBackend: PlayerBackend { clientTimer.resume() } + private var handleSegmentsThrottle = Throttle(interval: 1) + private func getClientUpdates() { self.logger.info("getting client updates") @@ -262,8 +264,10 @@ final class MPVBackend: PlayerBackend { model.updateNowPlayingInfo() - if let currentTime = currentTime { - model.handleSegments(at: currentTime) + handleSegmentsThrottle.execute { + if let currentTime = currentTime { + model.handleSegments(at: currentTime) + } } timeObserverThrottle.execute {