Code Block if AVPictureInPictureController.isPictureInPictureSupported(), let player = self.player{ |
let layer = AVPlayerLayer.init(player: player); |
self.pipController = AVPictureInPictureController.init(playerLayer: layer); |
self.pipController?.delegate = self; |
print("[\(#function)] create pip player[\(self.player?.description ?? "")] pip[\(self.pipController?.description ?? "")] allow]\(self.playerViewController.allowsPictureInPicturePlayback)]"); |
|
if self.pipController?.isPictureInPicturePossible ?? false{ |
self.pipController?.startPictureInPicture(); |
print("[\(#function)] start pip[\(self.pipController?.description ?? "")]"); |
|
} |
self.pipObserver = self.pipController?.observe(\AVPictureInPictureController.isPictureInPicturePossible, options: [.new], changeHandler: { (pip, change) in //.initial, |
print("[\(#function)] isPictureInPicturePossible[\(change.newValue.debugDescription ?? "")]"); |
}); |
// |
} |
=>
[startPlayingInPIP()] create pip player[<AVPlayer: 0x281a7f920>] pip[<AVPictureInPictureController: 0x283ce5020>] allow]true]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(true)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(false)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(true)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(false)]
....
[startPlayingInPIP()] isPictureInPicturePossible[Optional(true)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(false)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(true)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(false)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(true)]
[startPlayingInPIP()] isPictureInPicturePossible[Optional(false)]
what's this??