2022-02-17 01:53:11 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
#if !os(macOS)
|
|
|
|
struct MPVPlayerView: UIViewControllerRepresentable {
|
|
|
|
func makeUIViewController(context _: Context) -> some UIViewController {
|
2022-11-25 02:06:05 +05:30
|
|
|
PlayerModel.shared.mpvController
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
struct MPVPlayerView: NSViewRepresentable {
|
2022-02-28 02:01:17 +05:30
|
|
|
@State private var client = MPVClient()
|
|
|
|
@State private var layer = VideoLayer()
|
|
|
|
|
2022-02-17 01:53:11 +05:30
|
|
|
func makeNSView(context _: Context) -> some NSView {
|
2022-11-25 02:06:05 +05:30
|
|
|
PlayerModel.shared.mpvBackend.client = client
|
2022-03-21 02:01:19 +05:30
|
|
|
|
2022-02-28 02:01:17 +05:30
|
|
|
let view = MPVOGLView()
|
|
|
|
|
2022-11-12 00:25:18 +05:30
|
|
|
if !YatteeApp.isForPreviews {
|
|
|
|
client.layer = layer
|
|
|
|
layer.client = client
|
|
|
|
|
|
|
|
view.layer = client.layer
|
|
|
|
view.wantsLayer = true
|
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
|
2022-02-28 02:01:17 +05:30
|
|
|
return view
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func updateNSView(_: NSViewType, context _: Context) {}
|
|
|
|
}
|
|
|
|
#endif
|