feat: for tvOS
This commit is contained in:
@@ -31,7 +31,9 @@ struct NativePlayerView: UIViewControllerRepresentable {
|
||||
func makeUIViewController(context: Context) -> AVPlayerViewController {
|
||||
let vc = AVPlayerViewController()
|
||||
vc.player = player
|
||||
#if !os(tvOS)
|
||||
vc.allowsPictureInPicturePlayback = true
|
||||
#endif
|
||||
return vc
|
||||
}
|
||||
|
||||
@@ -52,18 +54,43 @@ struct VideoPlayerView: View {
|
||||
|
||||
@State private var viewModel = PlayerViewModel()
|
||||
|
||||
#if os(iOS)
|
||||
#if !os(macOS)
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
macOSPlayer
|
||||
#elseif os(tvOS)
|
||||
tvOSPlayer
|
||||
#else
|
||||
iOSPlayer
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(tvOS)
|
||||
private var tvOSPlayer: some View {
|
||||
Group {
|
||||
if let player = viewModel.player {
|
||||
NativePlayerView(player: player)
|
||||
.ignoresSafeArea()
|
||||
} else {
|
||||
ZStack {
|
||||
Color.black.ignoresSafeArea()
|
||||
ProgressView()
|
||||
.tint(.white)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
viewModel.play(url: url, contentId: contentId, episodeId: episodeId)
|
||||
}
|
||||
.onDisappear {
|
||||
viewModel.stop()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
private var iOSPlayer: some View {
|
||||
ZStack {
|
||||
|
||||
Reference in New Issue
Block a user