mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
@@ -129,6 +129,7 @@ final class PlayerModel: ObservableObject {
|
||||
#if os(iOS)
|
||||
@Published var lockedOrientation: UIInterfaceOrientationMask?
|
||||
@Default(.rotateToPortraitOnExitFullScreen) private var rotateToPortraitOnExitFullScreen
|
||||
@Default(.rotateToLandscapeOnEnterFullScreen) private var rotateToLandscapeOnEnterFullScreen
|
||||
#endif
|
||||
|
||||
var accounts: AccountsModel { .shared }
|
||||
@@ -981,24 +982,21 @@ final class PlayerModel: ObservableObject {
|
||||
Windows.player.toggleFullScreen()
|
||||
#endif
|
||||
|
||||
playingFullScreen = !isFullScreen
|
||||
|
||||
#if os(iOS)
|
||||
if !playingFullScreen {
|
||||
playingFullScreen = true
|
||||
Orientation.lockOrientation(.allButUpsideDown)
|
||||
if playingFullScreen {
|
||||
guard rotateToLandscapeOnEnterFullScreen.isRotating else { return }
|
||||
if currentVideoIsLandscape {
|
||||
// not sure why but first rotation call is ignore so doing rotate to same orientation first
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: OrientationTracker.shared.currentInterfaceOrientation)
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: rotateToLandscapeOnEnterFullScreen.interaceOrientation)
|
||||
}
|
||||
} else {
|
||||
let rotationOrientation = rotateToPortraitOnExitFullScreen ? UIInterfaceOrientation.portrait : nil
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: rotationOrientation)
|
||||
// TODO: rework to move view before rotating
|
||||
if SafeArea.insets.left > 0 {
|
||||
Delay.by(0.15) {
|
||||
self.playingFullScreen = false
|
||||
}
|
||||
} else {
|
||||
self.playingFullScreen = false
|
||||
}
|
||||
}
|
||||
#else
|
||||
playingFullScreen = !isFullScreen
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1036,6 +1034,12 @@ final class PlayerModel: ObservableObject {
|
||||
#endif
|
||||
}
|
||||
|
||||
var currentVideoIsLandscape: Bool {
|
||||
guard currentVideo != nil else { return false }
|
||||
|
||||
return aspectRatio > 1
|
||||
}
|
||||
|
||||
var formattedSize: String {
|
||||
guard let videoWidth = backend?.videoWidth, let videoHeight = backend?.videoHeight else { return "unknown" }
|
||||
return "\(String(format: "%.2f", videoWidth))\u{d7}\(String(format: "%.2f", videoHeight))"
|
||||
|
Reference in New Issue
Block a user