2022-02-16 20:23:11 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
#if !os(macOS)
|
|
|
|
struct MPVPlayerView: UIViewControllerRepresentable {
|
2022-02-27 20:31:17 +00:00
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
|
|
|
|
2022-02-16 20:23:11 +00:00
|
|
|
func makeUIViewController(context _: Context) -> some UIViewController {
|
2022-08-14 16:53:03 +00:00
|
|
|
player.mpvController
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
struct MPVPlayerView: NSViewRepresentable {
|
2022-02-27 20:31:17 +00:00
|
|
|
@State private var client = MPVClient()
|
|
|
|
@State private var layer = VideoLayer()
|
|
|
|
|
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
2022-02-16 20:23:11 +00:00
|
|
|
|
|
|
|
func makeNSView(context _: Context) -> some NSView {
|
2022-03-20 20:31:19 +00:00
|
|
|
player.mpvBackend.client = client
|
|
|
|
|
2022-02-27 20:31:17 +00:00
|
|
|
client.layer = layer
|
|
|
|
layer.client = client
|
|
|
|
|
|
|
|
let view = MPVOGLView()
|
|
|
|
|
|
|
|
view.layer = client.layer
|
|
|
|
view.wantsLayer = true
|
2022-02-16 20:23:11 +00:00
|
|
|
|
2022-02-27 20:31:17 +00:00
|
|
|
return view
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func updateNSView(_: NSViewType, context _: Context) {}
|
|
|
|
}
|
|
|
|
#endif
|