mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add setting "Rotate to portrait when exiting fullscreen"
This commit is contained in:
parent
8e2c30bf00
commit
0365369dcd
@ -156,12 +156,6 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
avPlayer.replaceCurrentItem(with: nil)
|
avPlayer.replaceCurrentItem(with: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func enterFullScreen() {
|
|
||||||
model.toggleFullscreen(model?.playingFullScreen ?? false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func exitFullScreen() {}
|
|
||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
func closePiP(wasPlaying: Bool) {
|
func closePiP(wasPlaying: Bool) {
|
||||||
let item = avPlayer.currentItem
|
let item = avPlayer.currentItem
|
||||||
|
@ -318,12 +318,6 @@ final class MPVBackend: PlayerBackend {
|
|||||||
client?.stop()
|
client?.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func enterFullScreen() {
|
|
||||||
model.toggleFullscreen(model?.playingFullScreen ?? false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func exitFullScreen() {}
|
|
||||||
|
|
||||||
func closePiP(wasPlaying _: Bool) {}
|
func closePiP(wasPlaying _: Bool) {}
|
||||||
|
|
||||||
func updateControls() {
|
func updateControls() {
|
||||||
|
@ -45,9 +45,6 @@ protocol PlayerBackend {
|
|||||||
|
|
||||||
func closeItem()
|
func closeItem()
|
||||||
|
|
||||||
func enterFullScreen()
|
|
||||||
func exitFullScreen()
|
|
||||||
|
|
||||||
func closePiP(wasPlaying: Bool)
|
func closePiP(wasPlaying: Bool)
|
||||||
|
|
||||||
func updateControls()
|
func updateControls()
|
||||||
|
@ -95,6 +95,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@Published var lockedOrientation: UIInterfaceOrientationMask?
|
@Published var lockedOrientation: UIInterfaceOrientationMask?
|
||||||
|
@Default(.rotateToPortraitOnExitFullScreen) private var rotateToPortraitOnExitFullScreen
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var accounts: AccountsModel
|
var accounts: AccountsModel
|
||||||
@ -103,6 +104,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
backends.forEach { backend in
|
backends.forEach { backend in
|
||||||
var backend = backend
|
var backend = backend
|
||||||
backend.controls = controls
|
backend.controls = controls
|
||||||
|
backend.controls.player = self
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
var playerTime: PlayerTimeModel { didSet {
|
var playerTime: PlayerTimeModel { didSet {
|
||||||
@ -741,28 +743,18 @@ final class PlayerModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func enterFullScreen() {
|
func enterFullScreen(showControls: Bool = true) {
|
||||||
guard !playingFullScreen else {
|
guard !playingFullScreen else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("entering fullscreen")
|
logger.info("entering fullscreen")
|
||||||
|
toggleFullscreen(false, showControls: showControls)
|
||||||
backend.enterFullScreen()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func exitFullScreen() {
|
func exitFullScreen(showControls: Bool = true) {
|
||||||
guard playingFullScreen else {
|
guard playingFullScreen else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("exiting fullscreen")
|
logger.info("exiting fullscreen")
|
||||||
|
toggleFullscreen(true, showControls: showControls)
|
||||||
if playingFullScreen {
|
|
||||||
toggleFullscreen(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
backend.exitFullScreen()
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -822,8 +814,8 @@ final class PlayerModel: ObservableObject {
|
|||||||
task.resume()
|
task.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleFullscreen(_ isFullScreen: Bool) {
|
func toggleFullscreen(_ isFullScreen: Bool, showControls: Bool = true) {
|
||||||
controls.presentingControls = false
|
controls.presentingControls = showControls && isFullScreen
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
if isFullScreen {
|
if isFullScreen {
|
||||||
@ -848,7 +840,8 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if !playingFullScreen {
|
if !playingFullScreen {
|
||||||
Orientation.lockOrientation(.allButUpsideDown)
|
let rotationOrientation = rotateToPortraitOnExitFullScreen ? UIInterfaceOrientation.portrait : nil
|
||||||
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: rotationOrientation)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ extension Defaults.Keys {
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
static let honorSystemOrientationLock = Key<Bool>("honorSystemOrientationLock", default: true)
|
static let honorSystemOrientationLock = Key<Bool>("honorSystemOrientationLock", default: true)
|
||||||
static let enterFullscreenInLandscape = Key<Bool>("enterFullscreenInLandscape", default: UIDevice.current.userInterfaceIdiom == .phone)
|
static let enterFullscreenInLandscape = Key<Bool>("enterFullscreenInLandscape", default: UIDevice.current.userInterfaceIdiom == .phone)
|
||||||
|
static let rotateToPortraitOnExitFullScreen = Key<Bool>("rotateToPortraitOnExitFullScreen", default: UIDevice.current.userInterfaceIdiom == .phone)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static let showMPVPlaybackStats = Key<Bool>("showMPVPlaybackStats", default: false)
|
static let showMPVPlaybackStats = Key<Bool>("showMPVPlaybackStats", default: false)
|
||||||
|
@ -415,7 +415,7 @@ struct VideoPlayerView: View {
|
|||||||
{
|
{
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
player.controls.presentingControls = false
|
player.controls.presentingControls = false
|
||||||
player.enterFullScreen()
|
player.enterFullScreen(showControls: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,10 +447,10 @@ struct VideoPlayerView: View {
|
|||||||
|
|
||||||
if orientation.isLandscape {
|
if orientation.isLandscape {
|
||||||
player.controls.presentingControls = false
|
player.controls.presentingControls = false
|
||||||
player.enterFullScreen()
|
player.enterFullScreen(showControls: false)
|
||||||
Orientation.lockOrientation(OrientationTracker.shared.currentInterfaceOrientationMask, andRotateTo: orientation)
|
Orientation.lockOrientation(OrientationTracker.shared.currentInterfaceOrientationMask, andRotateTo: orientation)
|
||||||
} else {
|
} else {
|
||||||
player.exitFullScreen()
|
player.exitFullScreen(showControls: false)
|
||||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait)
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ struct PlayerSettings: View {
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@Default(.honorSystemOrientationLock) private var honorSystemOrientationLock
|
@Default(.honorSystemOrientationLock) private var honorSystemOrientationLock
|
||||||
@Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape
|
@Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape
|
||||||
|
@Default(.rotateToPortraitOnExitFullScreen) private var rotateToPortraitOnExitFullScreen
|
||||||
#endif
|
#endif
|
||||||
@Default(.closePiPOnNavigation) private var closePiPOnNavigation
|
@Default(.closePiPOnNavigation) private var closePiPOnNavigation
|
||||||
@Default(.closePiPOnOpeningPlayer) private var closePiPOnOpeningPlayer
|
@Default(.closePiPOnOpeningPlayer) private var closePiPOnOpeningPlayer
|
||||||
@ -84,6 +85,16 @@ struct PlayerSettings: View {
|
|||||||
returnYouTubeDislikeToggle
|
returnYouTubeDislikeToggle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if os(iOS)
|
||||||
|
Section(header: SettingsHeader(text: "Orientation")) {
|
||||||
|
if idiom == .pad {
|
||||||
|
enterFullscreenInLandscapeToggle
|
||||||
|
}
|
||||||
|
rotateToPortraitOnExitFullScreenToggle
|
||||||
|
honorSystemOrientationLockToggle
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Section(header: SettingsHeader(text: "Picture in Picture")) {
|
Section(header: SettingsHeader(text: "Picture in Picture")) {
|
||||||
closePiPOnNavigationToggle
|
closePiPOnNavigationToggle
|
||||||
closePiPOnOpeningPlayerToggle
|
closePiPOnOpeningPlayerToggle
|
||||||
@ -91,15 +102,6 @@ struct PlayerSettings: View {
|
|||||||
closePiPAndOpenPlayerOnEnteringForegroundToggle
|
closePiPAndOpenPlayerOnEnteringForegroundToggle
|
||||||
#endif
|
#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 {
|
private var enterFullscreenInLandscapeToggle: some View {
|
||||||
Toggle("Enter fullscreen in landscape", isOn: $enterFullscreenInLandscape)
|
Toggle("Enter fullscreen in landscape", isOn: $enterFullscreenInLandscape)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var rotateToPortraitOnExitFullScreenToggle: some View {
|
||||||
|
Toggle("Rotate to portrait when exiting fullscreen", isOn: $rotateToPortraitOnExitFullScreen)
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private var closePiPOnNavigationToggle: some View {
|
private var closePiPOnNavigationToggle: some View {
|
||||||
|
Loading…
Reference in New Issue
Block a user