From df96c2dba07702d01149829ad33092a5d9e8cc75 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 1 Sep 2022 20:10:53 +0200 Subject: [PATCH] Fix updating playing status --- Model/Player/Backends/AVPlayerBackend.swift | 9 ++++++++- Model/Player/Backends/MPVBackend.swift | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Model/Player/Backends/AVPlayerBackend.swift b/Model/Player/Backends/AVPlayerBackend.swift index 7a218d6b..0fca77a2 100644 --- a/Model/Player/Backends/AVPlayerBackend.swift +++ b/Model/Player/Backends/AVPlayerBackend.swift @@ -521,6 +521,12 @@ final class AVPlayerBackend: PlayerBackend { MPNowPlayingInfoCenter.default().playbackState = self.avPlayer.timeControlStatus == .playing ? .playing : .paused #endif + if self.controls.isPlaying != self.isPlaying { + DispatchQueue.main.async { + self.controls.isPlaying = self.isPlaying + } + } + if let currentTime = self.currentTime { self.model.handleSegments(at: currentTime) } @@ -562,7 +568,8 @@ final class AVPlayerBackend: PlayerBackend { private func addPlayerTimeControlStatusObserver() { playerTimeControlStatusObserver = avPlayer.observe(\.timeControlStatus) { [weak self] player, _ in guard let self = self, - self.avPlayer == player + self.avPlayer == player, + self.model.activeBackend == .appleAVPlayer else { return } diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index b4774b6c..71ab8e7b 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -366,6 +366,7 @@ final class MPVBackend: PlayerBackend { } private func updateControlsIsPlaying() { + guard model.activeBackend == .mpv else { return } DispatchQueue.main.async { [weak self] in self?.controls?.isPlaying = self?.isPlaying ?? false }