Add setting "Rotate to portrait when exiting fullscreen"

This commit is contained in:
Arkadiusz Fal
2022-08-07 13:48:50 +02:00
parent 8e2c30bf00
commit 0365369dcd
7 changed files with 31 additions and 46 deletions

View File

@@ -94,6 +94,7 @@ extension Defaults.Keys {
#if os(iOS)
static let honorSystemOrientationLock = Key<Bool>("honorSystemOrientationLock", default: true)
static let enterFullscreenInLandscape = Key<Bool>("enterFullscreenInLandscape", default: UIDevice.current.userInterfaceIdiom == .phone)
static let rotateToPortraitOnExitFullScreen = Key<Bool>("rotateToPortraitOnExitFullScreen", default: UIDevice.current.userInterfaceIdiom == .phone)
#endif
static let showMPVPlaybackStats = Key<Bool>("showMPVPlaybackStats", default: false)

View File

@@ -415,7 +415,7 @@ struct VideoPlayerView: View {
{
DispatchQueue.main.async {
player.controls.presentingControls = false
player.enterFullScreen()
player.enterFullScreen(showControls: false)
}
}
@@ -447,10 +447,10 @@ struct VideoPlayerView: View {
if orientation.isLandscape {
player.controls.presentingControls = false
player.enterFullScreen()
player.enterFullScreen(showControls: false)
Orientation.lockOrientation(OrientationTracker.shared.currentInterfaceOrientationMask, andRotateTo: orientation)
} else {
player.exitFullScreen()
player.exitFullScreen(showControls: false)
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait)
}
}

View File

@@ -14,6 +14,7 @@ struct PlayerSettings: View {
#if os(iOS)
@Default(.honorSystemOrientationLock) private var honorSystemOrientationLock
@Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape
@Default(.rotateToPortraitOnExitFullScreen) private var rotateToPortraitOnExitFullScreen
#endif
@Default(.closePiPOnNavigation) private var closePiPOnNavigation
@Default(.closePiPOnOpeningPlayer) private var closePiPOnOpeningPlayer
@@ -84,6 +85,16 @@ struct PlayerSettings: View {
returnYouTubeDislikeToggle
}
#if os(iOS)
Section(header: SettingsHeader(text: "Orientation")) {
if idiom == .pad {
enterFullscreenInLandscapeToggle
}
rotateToPortraitOnExitFullScreenToggle
honorSystemOrientationLockToggle
}
#endif
Section(header: SettingsHeader(text: "Picture in Picture")) {
closePiPOnNavigationToggle
closePiPOnOpeningPlayerToggle
@@ -91,15 +102,6 @@ struct PlayerSettings: View {
closePiPAndOpenPlayerOnEnteringForegroundToggle
#endif
}
#if os(iOS)
Section(header: SettingsHeader(text: "Orientation")) {
if idiom == .pad {
enterFullscreenInLandscapeToggle
}
honorSystemOrientationLockToggle
}
#endif
}
}
@@ -196,6 +198,10 @@ struct PlayerSettings: View {
private var enterFullscreenInLandscapeToggle: some View {
Toggle("Enter fullscreen in landscape", isOn: $enterFullscreenInLandscape)
}
private var rotateToPortraitOnExitFullScreenToggle: some View {
Toggle("Rotate to portrait when exiting fullscreen", isOn: $rotateToPortraitOnExitFullScreen)
}
#endif
private var closePiPOnNavigationToggle: some View {