Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tvOS][QOL] Supports back button click when in the native player. #947

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Shared/Coordinators/VideoPlayerCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2023 Jellyfin & Jellyfin Contributors
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//

import Defaults
Expand Down Expand Up @@ -46,18 +46,16 @@ final class VideoPlayerCoordinator: NavigationCoordinatable {
}

#else

PreferenceUIHostingControllerView {
Group {
if Defaults[.VideoPlayer.videoPlayerType] == .swiftfin {
if Defaults[.VideoPlayer.videoPlayerType] == .swiftfin {
PreferenceUIHostingControllerView {
Group {
nokeeo marked this conversation as resolved.
Show resolved Hide resolved
VideoPlayer(manager: self.videoPlayerManager)
} else {
NativeVideoPlayer(manager: self.videoPlayerManager)
}
}
.ignoresSafeArea()
} else {
NativeVideoPlayer(manager: self.videoPlayerManager)
}
.ignoresSafeArea()

#endif
#endif
}
}
6 changes: 4 additions & 2 deletions Swiftfin tvOS/Views/VideoPlayer/NativeVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2023 Jellyfin & Jellyfin Contributors
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//

import AVKit
Expand Down Expand Up @@ -37,7 +37,7 @@ struct NativeVideoPlayer: View {
if let _ = videoPlayerManager.currentViewModel {
playerView
} else {
// VideoPlayer.LoadingView()
nokeeo marked this conversation as resolved.
Show resolved Hide resolved
// TODO: Implement more polished loading screen.
nokeeo marked this conversation as resolved.
Show resolved Hide resolved
Text("Loading")
}
}
Expand All @@ -57,6 +57,8 @@ struct NativeVideoPlayerView: UIViewControllerRepresentable {
func updateUIViewController(_ uiViewController: UINativeVideoPlayerViewController, context: Context) {}
}

// TODO: Refactor such that this does not subclass AVPlayerViewController. Subclassing is not
// supported according to the apple docs.
class UINativeVideoPlayerViewController: AVPlayerViewController {

let videoPlayerManager: VideoPlayerManager
Expand Down
Loading