mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Rotation fixes
This commit is contained in:
parent
d7a2564617
commit
d996069a20
@ -1023,6 +1023,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
if playingFullScreen {
|
if playingFullScreen {
|
||||||
if activeBackend == .appleAVPlayer, avPlayerUsesSystemControls {
|
if activeBackend == .appleAVPlayer, avPlayerUsesSystemControls {
|
||||||
avPlayerBackend.controller.enterFullScreen(animated: true)
|
avPlayerBackend.controller.enterFullScreen(animated: true)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
guard rotateToLandscapeOnEnterFullScreen.isRotating else { return }
|
guard rotateToLandscapeOnEnterFullScreen.isRotating else { return }
|
||||||
if currentVideoIsLandscape {
|
if currentVideoIsLandscape {
|
||||||
@ -1038,6 +1039,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
if activeBackend == .appleAVPlayer, avPlayerUsesSystemControls {
|
if activeBackend == .appleAVPlayer, avPlayerUsesSystemControls {
|
||||||
avPlayerBackend.controller.exitFullScreen(animated: true)
|
avPlayerBackend.controller.exitFullScreen(animated: true)
|
||||||
avPlayerBackend.controller.dismiss(animated: true)
|
avPlayerBackend.controller.dismiss(animated: true)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
let rotationOrientation = rotateToPortraitOnExitFullScreen ? UIInterfaceOrientation.portrait : nil
|
let rotationOrientation = rotateToPortraitOnExitFullScreen ? UIInterfaceOrientation.portrait : nil
|
||||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: rotationOrientation)
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: rotationOrientation)
|
||||||
|
@ -4,6 +4,11 @@ import SwiftUI
|
|||||||
|
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
final class AppleAVPlayerViewControllerDelegate: NSObject, AVPlayerViewControllerDelegate {
|
final class AppleAVPlayerViewControllerDelegate: NSObject, AVPlayerViewControllerDelegate {
|
||||||
|
#if os(iOS)
|
||||||
|
@Default(.rotateToLandscapeOnEnterFullScreen) private var rotateToLandscapeOnEnterFullScreen
|
||||||
|
@Default(.avPlayerUsesSystemControls) private var avPlayerUsesSystemControls
|
||||||
|
#endif
|
||||||
|
|
||||||
var player: PlayerModel { .shared }
|
var player: PlayerModel { .shared }
|
||||||
|
|
||||||
func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(_: AVPlayerViewController) -> Bool {
|
func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(_: AVPlayerViewController) -> Bool {
|
||||||
@ -11,10 +16,19 @@ import SwiftUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
func playerViewController(_: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator) {
|
func playerViewController(_: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator) {
|
||||||
Delay.by(0.5) { [weak self] in
|
#if os(iOS)
|
||||||
self?.player.playingFullScreen = true
|
guard rotateToLandscapeOnEnterFullScreen.isRotating else { return }
|
||||||
|
if PlayerModel.shared.currentVideoIsLandscape {
|
||||||
|
let delay = PlayerModel.shared.activeBackend == .appleAVPlayer && avPlayerUsesSystemControls ? 0.8 : 0
|
||||||
|
// not sure why but first rotation call is ignore so doing rotate to same orientation first
|
||||||
|
Delay.by(delay) {
|
||||||
|
let orientation = OrientationTracker.shared.currentDeviceOrientation.isLandscape ? OrientationTracker.shared.currentInterfaceOrientation : self.rotateToLandscapeOnEnterFullScreen.interaceOrientation
|
||||||
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: OrientationTracker.shared.currentInterfaceOrientation)
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user