diff --git a/Model/Player/PiPDelegate.swift b/Model/Player/PiPDelegate.swift index 2a33e98e..7f4db8fa 100644 --- a/Model/Player/PiPDelegate.swift +++ b/Model/Player/PiPDelegate.swift @@ -43,11 +43,18 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate { _: AVPictureInPictureController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void ) { + var delay = 0.0 + #if os(iOS) + if player.currentItem.isNil { + delay = 0.5 + } + #endif + if !player.currentItem.isNil { player?.show() } - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + DispatchQueue.main.asyncAfter(deadline: .now() + delay) { completionHandler(true) } } diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index 89fa9753..d0c336f4 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -206,9 +206,11 @@ final class PlayerModel: ObservableObject { } func play(_ video: Video, at time: CMTime? = nil, showingPlayer: Bool = true) { + pause() + var delay = 0.0 - #if !os(macOS) - delay = 0.3 + #if os(iOS) + delay = 0.5 #endif DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in