1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-27 23:40:35 +05:30

Fix build on tvOS

This commit is contained in:
Arkadiusz Fal 2023-06-07 23:19:00 +02:00
parent 7b9bbd8974
commit 7e7225c59f
2 changed files with 37 additions and 37 deletions

View File

@ -15,8 +15,8 @@ import SwiftUI
false false
} }
func playerViewController(_: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator) { #if os(iOS)
#if os(iOS) func playerViewController(_: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator) {
guard rotateToLandscapeOnEnterFullScreen.isRotating else { return } guard rotateToLandscapeOnEnterFullScreen.isRotating else { return }
if PlayerModel.shared.currentVideoIsLandscape { if PlayerModel.shared.currentVideoIsLandscape {
let delay = PlayerModel.shared.activeBackend == .appleAVPlayer && avPlayerUsesSystemControls ? 0.8 : 0 let delay = PlayerModel.shared.activeBackend == .appleAVPlayer && avPlayerUsesSystemControls ? 0.8 : 0
@ -27,34 +27,40 @@ import SwiftUI
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: orientation) Orientation.lockOrientation(.allButUpsideDown, andRotateTo: orientation)
} }
} }
#endif }
}
func playerViewController(_: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) { func playerViewController(_: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
let wasPlaying = player.isPlaying let wasPlaying = player.isPlaying
coordinator.animate(alongsideTransition: nil) { context in coordinator.animate(alongsideTransition: nil) { context in
#if os(iOS)
if wasPlaying { if wasPlaying {
self.player.play() self.player.play()
} }
#endif if !context.isCancelled {
if !context.isCancelled { #if os(iOS)
#if os(iOS) self.player.lockedOrientation = nil
self.player.lockedOrientation = nil
if Constants.isIPhone { if Constants.isIPhone {
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait) Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait)
} }
if wasPlaying { if wasPlaying {
self.player.play() self.player.play()
} }
self.player.playingFullScreen = false self.player.playingFullScreen = false
#endif #endif
}
} }
} }
}
func playerViewController(_: AVPlayerViewController, restoreUserInterfaceForFullScreenExitWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
withAnimation(nil) {
player.presentingPlayer = true
}
completionHandler(true)
}
#endif
func playerViewControllerWillStartPictureInPicture(_: AVPlayerViewController) {} func playerViewControllerWillStartPictureInPicture(_: AVPlayerViewController) {}
@ -86,14 +92,6 @@ import SwiftUI
} }
} }
} }
func playerViewController(_: AVPlayerViewController, restoreUserInterfaceForFullScreenExitWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
withAnimation(nil) {
player.presentingPlayer = true
}
completionHandler(true)
}
} }
#endif #endif

View File

@ -93,15 +93,17 @@ extension AppleAVPlayerViewController: AVPlayerViewControllerDelegate {
func playerViewControllerDidEndDismissalTransition(_: AVPlayerViewController) {} func playerViewControllerDidEndDismissalTransition(_: AVPlayerViewController) {}
func playerViewController( #if os(iOS)
_: AVPlayerViewController, func playerViewController(
willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator _: AVPlayerViewController,
) {} willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator
) {}
func playerViewController( func playerViewController(
_: AVPlayerViewController, _: AVPlayerViewController,
willEndFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator willEndFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator
) {} ) {}
#endif
func playerViewController( func playerViewController(
_: AVPlayerViewController, _: AVPlayerViewController,