mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
61a4951831
- player is now a separate window on macOS - add setting to disable pause when player is closed (fixes #40) - add PiP settings: * Close PiP when starting playing other video * Close PiP when player is opened * Close PiP and open player when application enters foreground (iOS/tvOS) (fixes #37) - new player placeholder when in PiP, context menu with exit option
35 lines
1.1 KiB
Swift
35 lines
1.1 KiB
Swift
import AVKit
|
|
import Foundation
|
|
|
|
final class PictureInPictureDelegate: NSObject, AVPlayerViewPictureInPictureDelegate {
|
|
var playerModel: PlayerModel!
|
|
|
|
func playerViewShouldAutomaticallyDismissAtPicture(inPictureStart _: AVPlayerView) -> Bool {
|
|
false
|
|
}
|
|
|
|
func playerViewWillStartPicture(inPicture _: AVPlayerView) {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
|
self?.playerModel.playingInPictureInPicture = true
|
|
self?.playerModel.hide()
|
|
}
|
|
}
|
|
|
|
func playerViewWillStopPicture(inPicture _: AVPlayerView) {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
|
self?.playerModel.playingInPictureInPicture = false
|
|
self?.playerModel.show()
|
|
}
|
|
}
|
|
|
|
func playerView(
|
|
_: AVPlayerView,
|
|
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: (Bool) -> Void
|
|
) {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
|
self?.playerModel.show()
|
|
}
|
|
completionHandler(true)
|
|
}
|
|
}
|