mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
36 lines
1.3 KiB
Swift
36 lines
1.3 KiB
Swift
|
import AVKit
|
||
|
import Foundation
|
||
|
|
||
|
final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate {
|
||
|
var player: PlayerModel!
|
||
|
|
||
|
func pictureInPictureController(
|
||
|
_: AVPictureInPictureController,
|
||
|
failedToStartPictureInPictureWithError error: Error
|
||
|
) {
|
||
|
print(error.localizedDescription)
|
||
|
}
|
||
|
|
||
|
func pictureInPictureControllerWillStartPictureInPicture(_: AVPictureInPictureController) {}
|
||
|
|
||
|
func pictureInPictureControllerDidStartPictureInPicture(_: AVPictureInPictureController) {}
|
||
|
|
||
|
func pictureInPictureControllerDidStopPictureInPicture(_: AVPictureInPictureController) {
|
||
|
if player?.avPlayerBackend.switchToMPVOnPipClose ?? false {
|
||
|
DispatchQueue.main.async { [weak player] in
|
||
|
player?.avPlayerBackend.switchToMPVOnPipClose = false
|
||
|
player?.saveTime { [weak player] in
|
||
|
player?.changeActiveBackend(from: .appleAVPlayer, to: .mpv)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func pictureInPictureControllerWillStopPictureInPicture(_: AVPictureInPictureController) {}
|
||
|
|
||
|
func pictureInPictureController(
|
||
|
_: AVPictureInPictureController,
|
||
|
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler _: @escaping (Bool) -> Void
|
||
|
) {}
|
||
|
}
|