Picture-in-Picture with SwiftUI Video Player

I've been trying to implement picture-in-picture support with the SwiftUI VideoPlayer view that AVKit offers. By default, it seems, there's no option for picture-in-picture with the system playback controls, so I tried building a custom control as an overlay.

Unfortunately, I couldn't get anything working. While AVPictureInPictureController.isPictureInPictureSupported() consistently returns true, the .isPictureInPicturePossible property always returns false, even though I've enabled the required background capability and configured the shared audio session properly. As a result, the .startPictureInPicture() method doesn't actually do anything. Strangely, none of the AVPictureInPictureControllerDelegate methods are ever called, even though my custom delegate instance is indeed properly configured.

How can I implement picture-in-picture support with the SwiftUI VideoPlayer view? I'd prefer not to have to use AVPlayerViewController.
Picture-in-Picture with SwiftUI Video Player
 
 
Q