From 32e98b6410937cb419b35f4be7f57029b62e600a Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 20 Dec 2022 23:21:37 +0100 Subject: [PATCH] Fix player --- Shared/Player/VideoPlayerView.swift | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index 05cd6493..722d2d5b 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -56,7 +56,7 @@ struct VideoPlayerView: View { @State internal var orientationNotification: Any? #endif - internal var player: PlayerModel! = PlayerModel.shared + @ObservedObject internal var player = PlayerModel.shared #if os(macOS) @ObservedObject private var navigation = NavigationModel.shared @@ -119,7 +119,7 @@ struct VideoPlayerView: View { } #if os(iOS) .frame(width: playerWidth.isNil ? nil : Double(playerWidth!), height: playerHeight.isNil ? nil : Double(playerHeight!)) - .ignoresSafeArea(.all, edges: playerEdgesIgnoringSafeArea) + .ignoresSafeArea(.all, edges: .bottom) .onChange(of: player.presentingPlayer) { newValue in if newValue { viewDragOffset = 0 @@ -271,18 +271,6 @@ struct VideoPlayerView: View { let lockedPortrait = player.lockedOrientation?.contains(.portrait) ?? false return fullScreenPlayer ? UIScreen.main.bounds.size.height - (OrientationTracker.shared.currentInterfaceOrientation.isPortrait || lockedPortrait ? (SafeArea.insets.top + SafeArea.insets.bottom) : 0) : nil } - - var playerEdgesIgnoringSafeArea: Edge.Set { - if let orientation = player.lockedOrientation, orientation.contains(.portrait) { - return [] - } - - if fullScreenPlayer, UIDevice.current.orientation.isLandscape { - return [.vertical] - } - - return [.bottom] - } #endif var content: some View { @@ -487,6 +475,10 @@ struct VideoPlayerView: View { struct VideoPlayerView_Previews: PreviewProvider { static var previews: some View { - VideoPlayerView() + ZStack { + Color.red + VideoPlayerView() + } + } }