yattee/Shared/Player/AppleAVPlayerView.swift

27 lines
780 B
Swift
Raw Normal View History

2022-05-20 21:23:14 +00:00
import AVKit
2021-09-25 08:18:22 +00:00
import Defaults
2021-07-18 22:32:46 +00:00
import SwiftUI
2022-08-20 21:05:40 +00:00
#if os(iOS)
struct AppleAVPlayerView: UIViewRepresentable {
func makeUIView(context _: Context) -> some UIView {
2023-04-22 13:08:33 +00:00
PlayerLayerView(frame: .zero)
2022-08-20 21:05:40 +00:00
}
func updateUIView(_: UIViewType, context _: Context) {}
2021-07-18 22:32:46 +00:00
}
2022-08-20 21:05:40 +00:00
#else
struct AppleAVPlayerView: UIViewControllerRepresentable {
func makeUIViewController(context _: Context) -> AppleAVPlayerViewController {
let controller = AppleAVPlayerViewController()
PlayerModel.shared.avPlayerBackend.controller = controller
2022-08-20 21:05:40 +00:00
return controller
}
func updateUIViewController(_: AppleAVPlayerViewController, context _: Context) {
PlayerModel.shared.rebuildTVMenu()
2022-08-20 21:05:40 +00:00
}
}
#endif