mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Add setting "Rotate to portrait when exiting fullscreen"
This commit is contained in:
@@ -156,12 +156,6 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
avPlayer.replaceCurrentItem(with: nil)
|
||||
}
|
||||
|
||||
func enterFullScreen() {
|
||||
model.toggleFullscreen(model?.playingFullScreen ?? false)
|
||||
}
|
||||
|
||||
func exitFullScreen() {}
|
||||
|
||||
#if os(tvOS)
|
||||
func closePiP(wasPlaying: Bool) {
|
||||
let item = avPlayer.currentItem
|
||||
|
@@ -318,12 +318,6 @@ final class MPVBackend: PlayerBackend {
|
||||
client?.stop()
|
||||
}
|
||||
|
||||
func enterFullScreen() {
|
||||
model.toggleFullscreen(model?.playingFullScreen ?? false)
|
||||
}
|
||||
|
||||
func exitFullScreen() {}
|
||||
|
||||
func closePiP(wasPlaying _: Bool) {}
|
||||
|
||||
func updateControls() {
|
||||
|
@@ -45,9 +45,6 @@ protocol PlayerBackend {
|
||||
|
||||
func closeItem()
|
||||
|
||||
func enterFullScreen()
|
||||
func exitFullScreen()
|
||||
|
||||
func closePiP(wasPlaying: Bool)
|
||||
|
||||
func updateControls()
|
||||
|
@@ -95,6 +95,7 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
#if os(iOS)
|
||||
@Published var lockedOrientation: UIInterfaceOrientationMask?
|
||||
@Default(.rotateToPortraitOnExitFullScreen) private var rotateToPortraitOnExitFullScreen
|
||||
#endif
|
||||
|
||||
var accounts: AccountsModel
|
||||
@@ -103,6 +104,7 @@ final class PlayerModel: ObservableObject {
|
||||
backends.forEach { backend in
|
||||
var backend = backend
|
||||
backend.controls = controls
|
||||
backend.controls.player = self
|
||||
}
|
||||
}}
|
||||
var playerTime: PlayerTimeModel { didSet {
|
||||
@@ -741,28 +743,18 @@ final class PlayerModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func enterFullScreen() {
|
||||
guard !playingFullScreen else {
|
||||
return
|
||||
}
|
||||
func enterFullScreen(showControls: Bool = true) {
|
||||
guard !playingFullScreen else { return }
|
||||
|
||||
logger.info("entering fullscreen")
|
||||
|
||||
backend.enterFullScreen()
|
||||
toggleFullscreen(false, showControls: showControls)
|
||||
}
|
||||
|
||||
func exitFullScreen() {
|
||||
guard playingFullScreen else {
|
||||
return
|
||||
}
|
||||
func exitFullScreen(showControls: Bool = true) {
|
||||
guard playingFullScreen else { return }
|
||||
|
||||
logger.info("exiting fullscreen")
|
||||
|
||||
if playingFullScreen {
|
||||
toggleFullscreen(true)
|
||||
}
|
||||
|
||||
backend.exitFullScreen()
|
||||
toggleFullscreen(true, showControls: showControls)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -822,8 +814,8 @@ final class PlayerModel: ObservableObject {
|
||||
task.resume()
|
||||
}
|
||||
|
||||
func toggleFullscreen(_ isFullScreen: Bool) {
|
||||
controls.presentingControls = false
|
||||
func toggleFullscreen(_ isFullScreen: Bool, showControls: Bool = true) {
|
||||
controls.presentingControls = showControls && isFullScreen
|
||||
|
||||
#if os(macOS)
|
||||
if isFullScreen {
|
||||
@@ -848,7 +840,8 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
#if os(iOS)
|
||||
if !playingFullScreen {
|
||||
Orientation.lockOrientation(.allButUpsideDown)
|
||||
let rotationOrientation = rotateToPortraitOnExitFullScreen ? UIInterfaceOrientation.portrait : nil
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: rotationOrientation)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user