mirror of
https://github.com/yattee/yattee.git
synced 2024-12-14 14:20:32 +05:30
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)
|
|
}
|
|
}
|