diff --git a/Model/Player/PiPDelegate.swift b/Model/Player/PiPDelegate.swift index 60d05f8a..2a33e98e 100644 --- a/Model/Player/PiPDelegate.swift +++ b/Model/Player/PiPDelegate.swift @@ -24,7 +24,8 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate { } if player.avPlayerBackend.switchToMPVOnPipClose, - !player.currentItem.isNil { + !player.currentItem.isNil + { DispatchQueue.main.async { player.avPlayerBackend.switchToMPVOnPipClose = false player.saveTime { @@ -45,7 +46,7 @@ final class PiPDelegate: NSObject, AVPictureInPictureControllerDelegate { if !player.currentItem.isNil { player?.show() } - + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { completionHandler(true) } diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index ecffd378..0854b98a 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -41,7 +41,7 @@ struct VideoPlayerView: View { var mouseLocation: CGPoint { NSEvent.mouseLocation } #endif - #if !os(macOS) + #if os(iOS) @State private var viewVerticalOffset = Self.hiddenOffset #endif @@ -74,31 +74,28 @@ struct VideoPlayerView: View { .onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in handleOrientationDidChangeNotification() } - #endif .onChange(of: player.presentingPlayer) { newValue in if newValue { viewVerticalOffset = 0 - #if os(iOS) - configureOrientationUpdatesBasedOnAccelerometer() - #endif + configureOrientationUpdatesBasedOnAccelerometer() } else { - #if os(iOS) - if Defaults[.lockPortraitWhenBrowsing] { - Orientation.lockOrientation(.portrait, andRotateTo: .portrait) - } else { - Orientation.lockOrientation(.allButUpsideDown) - } + if Defaults[.lockPortraitWhenBrowsing] { + Orientation.lockOrientation(.portrait, andRotateTo: .portrait) + } else { + Orientation.lockOrientation(.allButUpsideDown) + } - motionManager?.stopAccelerometerUpdates() - motionManager = nil - viewVerticalOffset = Self.hiddenOffset - #endif + motionManager?.stopAccelerometerUpdates() + motionManager = nil + viewVerticalOffset = Self.hiddenOffset } } + #endif } + #if os(iOS) .offset(y: viewVerticalOffset) - .opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1) .animation(.easeIn(duration: 0.2), value: viewVerticalOffset) + #endif #endif } diff --git a/Shared/Views/ChannelPlaylistView.swift b/Shared/Views/ChannelPlaylistView.swift index 8fa26809..d8653d18 100644 --- a/Shared/Views/ChannelPlaylistView.swift +++ b/Shared/Views/ChannelPlaylistView.swift @@ -62,7 +62,6 @@ struct ChannelPlaylistView: View { } } .offset(y: viewVerticalOffset) - .opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1) .animation(.easeIn(duration: 0.2), value: viewVerticalOffset) #endif } else { @@ -76,14 +75,16 @@ struct ChannelPlaylistView: View { VStack(alignment: .leading) { #if os(tvOS) HStack { - Text(playlist.title) - .font(.title2) - .frame(alignment: .leading) + if let playlist = presentedPlaylist { + Text(playlist.title) + .font(.title2) + .frame(alignment: .leading) - Spacer() + Spacer() - FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title))) - .labelStyle(.iconOnly) + FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title))) + .labelStyle(.iconOnly) + } playButton .labelStyle(.iconOnly) diff --git a/Shared/Views/ChannelVideosView.swift b/Shared/Views/ChannelVideosView.swift index 92c2e032..0cd4d03d 100644 --- a/Shared/Views/ChannelVideosView.swift +++ b/Shared/Views/ChannelVideosView.swift @@ -58,7 +58,6 @@ struct ChannelVideosView: View { } } .offset(y: viewVerticalOffset) - .opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1) .animation(.easeIn(duration: 0.2), value: viewVerticalOffset) #endif } else {