mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
Fix orientation on iOS 16
This commit is contained in:
parent
653cca07fe
commit
fc7052a7fa
@ -184,7 +184,7 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
private var currentArtwork: MPMediaItemArtwork?
|
||||
|
||||
var onPresentPlayer: (() -> Void)?
|
||||
var onPresentPlayer = [() -> Void]()
|
||||
private var remoteCommandCenterConfigured = false
|
||||
|
||||
init(
|
||||
@ -373,7 +373,7 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
#if os(iOS)
|
||||
if !playingInPictureInPicture, showingPlayer {
|
||||
onPresentPlayer = { [weak self] in
|
||||
onPresentPlayer.append { [weak self] in
|
||||
changeBackendHandler?()
|
||||
self?.playNow(video, at: time)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ extension PlayerModel {
|
||||
videos.forEach { enqueueVideo($0, loadDetails: false) }
|
||||
|
||||
#if os(iOS)
|
||||
onPresentPlayer = { [weak self] in self?.advanceToNextItem() }
|
||||
onPresentPlayer.append { [weak self] in self?.advanceToNextItem() }
|
||||
#else
|
||||
advanceToNextItem()
|
||||
#endif
|
||||
|
@ -183,8 +183,8 @@ struct VideoPlayerView: View {
|
||||
.onAnimationCompleted(for: viewDragOffset) {
|
||||
guard !dragGestureState else { return }
|
||||
if viewDragOffset == 0 {
|
||||
player.onPresentPlayer?()
|
||||
player.onPresentPlayer = nil
|
||||
player.onPresentPlayer.forEach { $0() }
|
||||
player.onPresentPlayer = []
|
||||
} else if viewDragOffset == Self.hiddenOffset {
|
||||
player.hide(animate: false)
|
||||
}
|
||||
@ -506,7 +506,9 @@ struct VideoPlayerView: View {
|
||||
player.enterFullScreen(showControls: false)
|
||||
}
|
||||
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: currentOrientation)
|
||||
player.onPresentPlayer.append {
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: currentOrientation)
|
||||
}
|
||||
}
|
||||
|
||||
orientationObserver = NotificationCenter.default.addObserver(
|
||||
|
@ -32,5 +32,17 @@ struct Orientation {
|
||||
|
||||
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
|
||||
UINavigationController.attemptRotationToDeviceOrientation()
|
||||
|
||||
if #available(iOS 16, *) {
|
||||
guard let windowScene = SafeArea.scene else { return }
|
||||
let rotateOrientationMask = rotateOrientation == .portrait ? UIInterfaceOrientationMask.portrait :
|
||||
rotateOrientation == .landscapeLeft ? .landscapeLeft :
|
||||
rotateOrientation == .landscapeRight ? .landscapeRight :
|
||||
.allButUpsideDown
|
||||
|
||||
windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: rotateOrientationMask)) { error in
|
||||
print("denied rotation \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user