File tree 1 file changed +10
-2
lines changed
bk2ch15p659SimplestAVKit/SimplestAVKit
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,11 @@ class ViewController: UIViewController {
23
23
}
24
24
25
25
26
-
26
+ var pic = false // is picture in picture going on?
27
27
let which = 1 // 1 is present, 2 is push, but they no longer talk about that
28
28
29
29
@IBAction func doPresent( _ sender: Any ) {
30
+ if self . pic { return } // don't do this in the middle of picture in picture
30
31
switch which {
31
32
case 1 :
32
33
let av = AVPlayerViewController ( )
@@ -99,11 +100,18 @@ extension ViewController : AVPlayerViewControllerDelegate {
99
100
100
101
101
102
func playerViewController( _ pvc: AVPlayerViewController , restoreUserInterfaceForPictureInPictureStopWithCompletionHandler ch: @escaping ( Bool ) -> Void ) {
102
- self . present ( pvc, animated: true ) {
103
+ self . present ( pvc, animated: true ) {
103
104
ch ( true )
104
105
}
105
106
}
106
107
108
+ func playerViewControllerDidStartPictureInPicture( _ playerViewController: AVPlayerViewController ) {
109
+ self . pic = true
110
+ }
111
+
112
+ func playerViewControllerDidStopPictureInPicture( _ playerViewController: AVPlayerViewController ) {
113
+ self . pic = false
114
+ }
107
115
108
116
}
109
117
You can’t perform that action at this time.
0 commit comments