mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
29 lines
848 B
Swift
29 lines
848 B
Swift
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)
|
|
}
|
|
}
|