From fa76f726c573c7fb2989fbf64d03622291ea67fa Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Fri, 19 Aug 2022 00:36:16 +0200 Subject: [PATCH] Show asset loading error from AVPlayer --- Model/Player/Backends/AVPlayerBackend.swift | 4 +++- Model/Player/PlayerModel.swift | 9 +++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Model/Player/Backends/AVPlayerBackend.swift b/Model/Player/Backends/AVPlayerBackend.swift index 7eb565c4..c64b1580 100644 --- a/Model/Player/Backends/AVPlayerBackend.swift +++ b/Model/Player/Backends/AVPlayerBackend.swift @@ -459,7 +459,9 @@ final class AVPlayerBackend: PlayerBackend { self.model.play() } case .failed: - self.model.playerError = item.error + DispatchQueue.main.async { + self.model.playerError = item.error + } default: return diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index 418b992d..748b1d95 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -149,13 +149,10 @@ final class PlayerModel: ObservableObject { var pipController: AVPictureInPictureController? var pipDelegate = PiPDelegate() - @Published var presentingErrorDetails = false var playerError: Error? { didSet { - #if !os(tvOS) - if !playerError.isNil { - presentingErrorDetails = true - } - #endif + if let error = playerError { + navigation.presentAlert(title: "Failed loading video", message: error.localizedDescription) + } }} @Default(.qualityProfiles) var qualityProfiles