Picture in Picture in Swift
1. **Picture-in-Picture (PiP) Mode**: - You can use the `AVPlayerViewController` class which supports PiP mode¹. - If you're building a custom video player, you can use `AVPictureInPictureController`². - To enable PiP mode automatically from inline, you can use `pictureInPictureController.canStartPictureInPictureAutomaticallyFromInline = true`⁴. 2. **Background Mode**: - To allow your app to perform tasks in the background, you need to enable the background capabilities in Xcode⁶. - You can use `BGAppRefreshTask` for short-duration tasks that expect quick results, such as downloading a stock quote⁶. - For tasks that might be time-consuming, such as downloading a large file or synchronizing data, you can use `BGProcessingTask`⁶. - You can also use the `application:performFetchWithCompletionHandler()` function which is invoked by the system every time the app is launched in the backgrou...