mirror of
https://github.com/yattee/yattee.git
synced 2024-11-12 17:18:22 +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?
|
private var currentArtwork: MPMediaItemArtwork?
|
||||||
|
|
||||||
var onPresentPlayer: (() -> Void)?
|
var onPresentPlayer = [() -> Void]()
|
||||||
private var remoteCommandCenterConfigured = false
|
private var remoteCommandCenterConfigured = false
|
||||||
|
|
||||||
init(
|
init(
|
||||||
@ -373,7 +373,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if !playingInPictureInPicture, showingPlayer {
|
if !playingInPictureInPicture, showingPlayer {
|
||||||
onPresentPlayer = { [weak self] in
|
onPresentPlayer.append { [weak self] in
|
||||||
changeBackendHandler?()
|
changeBackendHandler?()
|
||||||
self?.playNow(video, at: time)
|
self?.playNow(video, at: time)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ extension PlayerModel {
|
|||||||
videos.forEach { enqueueVideo($0, loadDetails: false) }
|
videos.forEach { enqueueVideo($0, loadDetails: false) }
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
onPresentPlayer = { [weak self] in self?.advanceToNextItem() }
|
onPresentPlayer.append { [weak self] in self?.advanceToNextItem() }
|
||||||
#else
|
#else
|
||||||
advanceToNextItem()
|
advanceToNextItem()
|
||||||
#endif
|
#endif
|
||||||
|
@ -183,8 +183,8 @@ struct VideoPlayerView: View {
|
|||||||
.onAnimationCompleted(for: viewDragOffset) {
|
.onAnimationCompleted(for: viewDragOffset) {
|
||||||
guard !dragGestureState else { return }
|
guard !dragGestureState else { return }
|
||||||
if viewDragOffset == 0 {
|
if viewDragOffset == 0 {
|
||||||
player.onPresentPlayer?()
|
player.onPresentPlayer.forEach { $0() }
|
||||||
player.onPresentPlayer = nil
|
player.onPresentPlayer = []
|
||||||
} else if viewDragOffset == Self.hiddenOffset {
|
} else if viewDragOffset == Self.hiddenOffset {
|
||||||
player.hide(animate: false)
|
player.hide(animate: false)
|
||||||
}
|
}
|
||||||
@ -506,7 +506,9 @@ struct VideoPlayerView: View {
|
|||||||
player.enterFullScreen(showControls: false)
|
player.enterFullScreen(showControls: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: currentOrientation)
|
player.onPresentPlayer.append {
|
||||||
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: currentOrientation)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orientationObserver = NotificationCenter.default.addObserver(
|
orientationObserver = NotificationCenter.default.addObserver(
|
||||||
|
@ -32,5 +32,17 @@ struct Orientation {
|
|||||||
|
|
||||||
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
|
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
|
||||||
UINavigationController.attemptRotationToDeviceOrientation()
|
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