1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 22:00:31 +05:30
yattee/macOS/PictureInPictureDelegate.swift

29 lines
848 B
Swift
Raw Normal View History

2021-10-28 22:44:55 +05:30
import AVKit
import Foundation
final class PictureInPictureDelegate: NSObject, AVPlayerViewPictureInPictureDelegate {
var playerModel: PlayerModel!
func playerViewShouldAutomaticallyDismissAtPicture(inPictureStart _: AVPlayerView) -> Bool {
false
}
func playerViewWillStartPicture(inPicture _: AVPlayerView) {
playerModel.playingInPictureInPicture = true
playerModel.presentingPlayer = false
}
func playerViewWillStopPicture(inPicture _: AVPlayerView) {
playerModel.playingInPictureInPicture = false
playerModel.presentPlayer()
}
func playerView(
_: AVPlayerView,
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: (Bool) -> Void
) {
playerModel.presentingPlayer = true
completionHandler(true)
}
}