From c86c08d4bb900ad3647df5545acc451cd1f02780 Mon Sep 17 00:00:00 2001 From: Aiden Vigue Date: Mon, 24 May 2021 18:14:11 -0400 Subject: [PATCH] player fixes --- JellyfinPlayer/ContentView.swift | 3 ++- JellyfinPlayer/EpisodeItemView.swift | 6 +++--- JellyfinPlayer/JellyfinPlayerApp.swift | 3 +-- JellyfinPlayer/MovieItemView.swift | 8 ++++---- JellyfinPlayer/VideoPlayerView.swift | 9 +++++---- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift index c02f74f5..d5606c65 100644 --- a/JellyfinPlayer/ContentView.swift +++ b/JellyfinPlayer/ContentView.swift @@ -136,7 +136,8 @@ class PreferenceUIHostingController: UIHostingController { // MARK: Lock orientation public var _orientations: UIInterfaceOrientationMask = .allButUpsideDown { - didSet { UIViewController.attemptRotationToDeviceOrientation(); + didSet { + UIViewController.attemptRotationToDeviceOrientation(); if(_orientations == .landscapeRight) { let value = UIInterfaceOrientation.landscapeRight.rawValue; UIDevice.current.setValue(value, forKey: "orientation") diff --git a/JellyfinPlayer/EpisodeItemView.swift b/JellyfinPlayer/EpisodeItemView.swift index 20526aa6..2e6d6b98 100644 --- a/JellyfinPlayer/EpisodeItemView.swift +++ b/JellyfinPlayer/EpisodeItemView.swift @@ -355,10 +355,10 @@ struct EpisodeItemView: View { WebImage(url: cast.Image) .resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size .placeholder { - Image(uiImage: UIImage(blurHash: (cast.ImageBlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : cast.ImageBlurHash), size: CGSize(width: 32, height: 32))!) + Image(uiImage: UIImage(blurHash: (cast.ImageBlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : cast.ImageBlurHash), size: CGSize(width: 4, height: 4))!) .resizable() .aspectRatio(contentMode: .fill) - .frame(width: 100, height: 100) + .frame(width: 70, height: 70) .cornerRadius(10) } .aspectRatio(contentMode: .fill) @@ -596,7 +596,7 @@ struct EpisodeItemView: View { }.introspectTabBarController { (UITabBarController) in UITabBarController.tabBar.isHidden = true } - }.onAppear(perform: loadData) + }.onAppear(perform: loadData).supportedOrientations(.allButUpsideDown) } } } diff --git a/JellyfinPlayer/JellyfinPlayerApp.swift b/JellyfinPlayer/JellyfinPlayerApp.swift index 90c2b8e1..3eac288c 100644 --- a/JellyfinPlayer/JellyfinPlayerApp.swift +++ b/JellyfinPlayer/JellyfinPlayerApp.swift @@ -61,8 +61,7 @@ struct JellyfinPlayerApp: App { .environmentObject(OrientationInfo()) .environmentObject(jsi) .withHostingWindow() { window in - window?.rootViewController = PreferenceUIHostingController(wrappedView: ContentView().environment(\.managedObjectContext, persistenceController.container.viewContext) - .environmentObject(jsi).environmentObject(OrientationInfo())) + window?.rootViewController = PreferenceUIHostingController(wrappedView: ContentView().environment(\.managedObjectContext, persistenceController.container.viewContext).environmentObject(OrientationInfo()).environmentObject(jsi)) } } } diff --git a/JellyfinPlayer/MovieItemView.swift b/JellyfinPlayer/MovieItemView.swift index 15fbcd35..e2313628 100644 --- a/JellyfinPlayer/MovieItemView.swift +++ b/JellyfinPlayer/MovieItemView.swift @@ -401,14 +401,14 @@ struct MovieItemView: View { WebImage(url: cast.Image) .resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size .placeholder { - Image(uiImage: UIImage(blurHash: (cast.ImageBlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : cast.ImageBlurHash), size: CGSize(width: 32, height: 32))!) + Image(uiImage: UIImage(blurHash: (cast.ImageBlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : cast.ImageBlurHash), size: CGSize(width: 4, height: 4))!) .resizable() .aspectRatio(contentMode: .fill) - .frame(width: 100, height: 100) + .frame(width: 70, height: 70) .cornerRadius(10) } .aspectRatio(contentMode: .fill) - .frame(width: 100, height: 100) + .frame(width: 70, height: 70) .cornerRadius(10).shadow(radius: 6) Text(cast.Name).font(.footnote).fontWeight(.regular).lineLimit(1).frame(width: 100).foregroundColor(Color.primary) if(cast.Role != "") { @@ -641,7 +641,7 @@ struct MovieItemView: View { }.introspectTabBarController { (UITabBarController) in UITabBarController.tabBar.isHidden = false } - }.onAppear(perform: loadData) + }.onAppear(perform: loadData).supportedOrientations(.allButUpsideDown) } } } diff --git a/JellyfinPlayer/VideoPlayerView.swift b/JellyfinPlayer/VideoPlayerView.swift index dfee0ca7..4eaa6f09 100644 --- a/JellyfinPlayer/VideoPlayerView.swift +++ b/JellyfinPlayer/VideoPlayerView.swift @@ -374,8 +374,9 @@ struct VideoPlayerView: View { VLCPlayer(url: $pbitem, player: $vlcplayer, startTime: Int(item.Progress)).onDisappear(perform: { _isPlaying.wrappedValue = false; vlcplayer.stop() - }) - }.overlay( + }).padding(EdgeInsets(top: 0, leading: UIDevice.current.hasNotch ? 30 : 0, bottom: 0, trailing: UIDevice.current.hasNotch ? 30 : 0)) + } + .overlay( VStack() { HStack() { HStack() { @@ -459,7 +460,6 @@ struct VideoPlayerView: View { Text(timeText).fontWeight(.semibold).frame(width: 80).foregroundColor(.white) }.padding(EdgeInsets(top: -20, leading: 44, bottom: 42, trailing: 40)) } - .padding(EdgeInsets(top: 0, leading: UIDevice.current.hasNotch ? -30 : 0, bottom: 0, trailing: UIDevice.current.hasNotch ? -30 : 0)) .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(.black).opacity(0.4)) .isHidden(inactivity) @@ -469,12 +469,13 @@ struct VideoPlayerView: View { .navigationBarHidden(true) .navigationBarBackButtonHidden(true) .prefersHomeIndicatorAutoHidden(true) + .edgesIgnoringSafeArea(.all) + .supportedOrientations(.landscapeRight) .preferredColorScheme(.dark) .introspectTabBarController { (UITabBarController) in UITabBarController.tabBar.isHidden = true } .statusBar(hidden: true) - .edgesIgnoringSafeArea(.all) .onTapGesture(perform: resetTimer) .fullScreenCover(isPresented: self.$captionConfiguration) { NavigationView() {