mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
Fix orientation issues
This commit is contained in:
parent
0049a68839
commit
fe9b7c03ca
@ -7,11 +7,13 @@ extension VideoPlayerView {
|
|||||||
let currentOrientation = OrientationTracker.shared.currentInterfaceOrientation
|
let currentOrientation = OrientationTracker.shared.currentInterfaceOrientation
|
||||||
if currentOrientation.isLandscape,
|
if currentOrientation.isLandscape,
|
||||||
Defaults[.enterFullscreenInLandscape],
|
Defaults[.enterFullscreenInLandscape],
|
||||||
|
!Defaults[.honorSystemOrientationLock],
|
||||||
!player.playingFullScreen,
|
!player.playingFullScreen,
|
||||||
!player.playingInPictureInPicture
|
!player.currentItem.isNil,
|
||||||
|
player.lockedOrientation.isNil || player.lockedOrientation!.contains(.landscape),
|
||||||
|
!player.playingInPictureInPicture,
|
||||||
|
player.presentingPlayer
|
||||||
{
|
{
|
||||||
guard player.presentingPlayer else { return }
|
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
player.controls.presentingControls = false
|
player.controls.presentingControls = false
|
||||||
player.enterFullScreen(showControls: false)
|
player.enterFullScreen(showControls: false)
|
||||||
|
@ -55,6 +55,7 @@ struct VideoPlayerView: View {
|
|||||||
@State internal var isVerticalDrag = false
|
@State internal var isVerticalDrag = false
|
||||||
@State internal var viewDragOffset = Self.hiddenOffset
|
@State internal var viewDragOffset = Self.hiddenOffset
|
||||||
@State internal var orientationObserver: Any?
|
@State internal var orientationObserver: Any?
|
||||||
|
@State internal var orientationNotification: Any?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@EnvironmentObject<PlayerModel> internal var player
|
@EnvironmentObject<PlayerModel> internal var player
|
||||||
@ -144,6 +145,8 @@ struct VideoPlayerView: View {
|
|||||||
orientationMask,
|
orientationMask,
|
||||||
andRotateTo: orientationMask == .landscapeLeft ? .landscapeLeft : orientationMask == .landscapeRight ? .landscapeRight : .portrait
|
andRotateTo: orientationMask == .landscapeLeft ? .landscapeLeft : orientationMask == .landscapeRight ? .landscapeRight : .portrait
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
Orientation.lockOrientation(.allButUpsideDown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,8 +158,13 @@ struct VideoPlayerView: View {
|
|||||||
}
|
}
|
||||||
stopOrientationUpdates()
|
stopOrientationUpdates()
|
||||||
player.controls.hideOverlays()
|
player.controls.hideOverlays()
|
||||||
|
}
|
||||||
|
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
|
||||||
|
guard player.lockedOrientation.isNil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
player.lockedOrientation = nil
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: OrientationTracker.shared.currentInterfaceOrientation)
|
||||||
}
|
}
|
||||||
.onAnimationCompleted(for: viewDragOffset) {
|
.onAnimationCompleted(for: viewDragOffset) {
|
||||||
guard !dragGestureState else { return }
|
guard !dragGestureState else { return }
|
||||||
|
Loading…
Reference in New Issue
Block a user