mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Fix PiP close on Mac
This commit is contained in:
@@ -2,6 +2,8 @@ import AVKit
|
||||
import Foundation
|
||||
|
||||
final class MacOSPiPDelegate: NSObject, AVPlayerViewPictureInPictureDelegate {
|
||||
static let shared = MacOSPiPDelegate()
|
||||
|
||||
var playerModel: PlayerModel { .shared }
|
||||
|
||||
func playerViewShouldAutomaticallyDismissAtPicture(inPictureStart _: AVPlayerView) -> Bool {
|
||||
@@ -16,19 +18,14 @@ final class MacOSPiPDelegate: NSObject, AVPlayerViewPictureInPictureDelegate {
|
||||
}
|
||||
|
||||
func playerViewWillStopPicture(inPicture _: AVPlayerView) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
||||
self?.playerModel.playingInPictureInPicture = false
|
||||
self?.playerModel.show()
|
||||
}
|
||||
playerModel.show()
|
||||
playerModel.playingInPictureInPicture = false
|
||||
}
|
||||
|
||||
func playerView(
|
||||
_: AVPlayerView,
|
||||
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: (Bool) -> Void
|
||||
) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
||||
self?.playerModel.show()
|
||||
}
|
||||
completionHandler(true)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user