diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index a903744f..694e388d 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -177,6 +177,7 @@ extension Defaults.Keys { static let visibleSections = Key>("visibleSections", default: [.subscriptions, .trending, .playlists]) #if os(iOS) + static let honorSystemOrientationLock = Key("honorSystemOrientationLock", default: true) static let enterFullscreenInLandscape = Key("enterFullscreenInLandscape", default: UIDevice.current.userInterfaceIdiom == .phone) static let rotateToPortraitOnExitFullScreen = Key("rotateToPortraitOnExitFullScreen", default: UIDevice.current.userInterfaceIdiom == .phone) #endif diff --git a/Shared/Player/PlayerOrientation.swift b/Shared/Player/PlayerOrientation.swift index ea889617..ed3b6826 100644 --- a/Shared/Player/PlayerOrientation.swift +++ b/Shared/Player/PlayerOrientation.swift @@ -8,9 +8,7 @@ extension VideoPlayerView { if currentOrientation.isLandscape, Defaults[.enterFullscreenInLandscape], !player.playingFullScreen, - !player.playingInPictureInPicture, - !player.currentItem.isNil, - player.lockedOrientation.isNil || player.lockedOrientation!.contains(.landscape) + !player.playingInPictureInPicture { guard player.presentingPlayer else { return } @@ -29,7 +27,8 @@ extension VideoPlayerView { object: nil, queue: .main ) { _ in - guard player.presentingPlayer, + guard !Defaults[.honorSystemOrientationLock], + player.presentingPlayer, !player.playingInPictureInPicture, player.lockedOrientation.isNil else { diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index 8d4b70e3..d6338c42 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -155,6 +155,8 @@ struct VideoPlayerView: View { } stopOrientationUpdates() player.controls.hideOverlays() + + player.lockedOrientation = nil } .onAnimationCompleted(for: viewDragOffset) { guard !dragGestureState else { return } diff --git a/Shared/Settings/PlayerSettings.swift b/Shared/Settings/PlayerSettings.swift index d27a706f..2e11437c 100644 --- a/Shared/Settings/PlayerSettings.swift +++ b/Shared/Settings/PlayerSettings.swift @@ -15,6 +15,7 @@ struct PlayerSettings: View { @Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer @Default(.closeLastItemOnPlaybackEnd) private var closeLastItemOnPlaybackEnd #if os(iOS) + @Default(.honorSystemOrientationLock) private var honorSystemOrientationLock @Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape @Default(.rotateToPortraitOnExitFullScreen) private var rotateToPortraitOnExitFullScreen #endif @@ -111,6 +112,7 @@ struct PlayerSettings: View { enterFullscreenInLandscapeToggle } rotateToPortraitOnExitFullScreenToggle + honorSystemOrientationLockToggle } #endif @@ -247,6 +249,11 @@ struct PlayerSettings: View { } #if os(iOS) + private var honorSystemOrientationLockToggle: some View { + Toggle("Honor orientation lock", isOn: $honorSystemOrientationLock) + .disabled(!enterFullscreenInLandscape) + } + private var enterFullscreenInLandscapeToggle: some View { Toggle("Enter fullscreen in landscape", isOn: $enterFullscreenInLandscape) }