From 7e7225c59f9d6cdf09788972a0b93bc685e2b428 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 7 Jun 2023 23:19:00 +0200 Subject: [PATCH] Fix build on tvOS --- Shared/Player/AppleAVPlayerView.swift | 56 +++++++++---------- .../Player/AppleAVPlayerViewController.swift | 18 +++--- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Shared/Player/AppleAVPlayerView.swift b/Shared/Player/AppleAVPlayerView.swift index 70b3a9aa..294bee82 100644 --- a/Shared/Player/AppleAVPlayerView.swift +++ b/Shared/Player/AppleAVPlayerView.swift @@ -15,8 +15,8 @@ import SwiftUI false } - func playerViewController(_: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator) { - #if os(iOS) + #if os(iOS) + func playerViewController(_: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator) { guard rotateToLandscapeOnEnterFullScreen.isRotating else { return } if PlayerModel.shared.currentVideoIsLandscape { let delay = PlayerModel.shared.activeBackend == .appleAVPlayer && avPlayerUsesSystemControls ? 0.8 : 0 @@ -27,34 +27,40 @@ import SwiftUI Orientation.lockOrientation(.allButUpsideDown, andRotateTo: orientation) } } - #endif - } + } - func playerViewController(_: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) { - let wasPlaying = player.isPlaying - coordinator.animate(alongsideTransition: nil) { context in - #if os(iOS) + func playerViewController(_: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) { + let wasPlaying = player.isPlaying + coordinator.animate(alongsideTransition: nil) { context in if wasPlaying { self.player.play() } - #endif - if !context.isCancelled { - #if os(iOS) - self.player.lockedOrientation = nil + if !context.isCancelled { + #if os(iOS) + self.player.lockedOrientation = nil - if Constants.isIPhone { - Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait) - } + if Constants.isIPhone { + Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait) + } - if wasPlaying { - self.player.play() - } + if wasPlaying { + self.player.play() + } - self.player.playingFullScreen = false - #endif + self.player.playingFullScreen = false + #endif + } } } - } + + func playerViewController(_: AVPlayerViewController, restoreUserInterfaceForFullScreenExitWithCompletionHandler completionHandler: @escaping (Bool) -> Void) { + withAnimation(nil) { + player.presentingPlayer = true + } + + completionHandler(true) + } + #endif 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 diff --git a/Shared/Player/AppleAVPlayerViewController.swift b/Shared/Player/AppleAVPlayerViewController.swift index 9fdc057d..c94ebed1 100644 --- a/Shared/Player/AppleAVPlayerViewController.swift +++ b/Shared/Player/AppleAVPlayerViewController.swift @@ -93,15 +93,17 @@ extension AppleAVPlayerViewController: AVPlayerViewControllerDelegate { func playerViewControllerDidEndDismissalTransition(_: AVPlayerViewController) {} - func playerViewController( - _: AVPlayerViewController, - willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator - ) {} + #if os(iOS) + func playerViewController( + _: AVPlayerViewController, + willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator + ) {} - func playerViewController( - _: AVPlayerViewController, - willEndFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator - ) {} + func playerViewController( + _: AVPlayerViewController, + willEndFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator + ) {} + #endif func playerViewController( _: AVPlayerViewController,