From 9db5fb0de7fdce65ed39aa7db9331d5f7356970c Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 23 Sep 2023 18:05:13 +0200 Subject: [PATCH] Handle core-idle property --- Model/Player/Backends/MPVBackend.swift | 8 ++++++++ Model/Player/Backends/MPVClient.swift | 1 + 2 files changed, 9 insertions(+) diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index e4359673..773251d8 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -605,6 +605,14 @@ final class MPVBackend: PlayerBackend { isPlaying = !paused networkStateTimer.start() } + case "core-idle": + if let idle = UnsafePointer(OpaquePointer(property.data))?.pointee { + if !idle { + isLoadingVideo = false + isSeeking = false + networkStateTimer.start() + } + } default: logger.info("MPV backend received unhandled property: \(name)") } diff --git a/Model/Player/Backends/MPVClient.swift b/Model/Player/Backends/MPVClient.swift index 138fa052..9b51f54a 100644 --- a/Model/Player/Backends/MPVClient.swift +++ b/Model/Player/Backends/MPVClient.swift @@ -109,6 +109,7 @@ final class MPVClient: ObservableObject { mpv_set_wakeup_callback(mpv, wakeUp, UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())) mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_FLAG) + mpv_observe_property(mpv, 0, "core-idle", MPV_FORMAT_FLAG) } func readEvents() {