mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 13:50:32 +05:30
35 lines
950 B
Swift
35 lines
950 B
Swift
import SwiftUI
|
|
|
|
#if !os(macOS)
|
|
struct MPVPlayerView: UIViewControllerRepresentable {
|
|
func makeUIViewController(context _: Context) -> some UIViewController {
|
|
PlayerModel.shared.mpvController
|
|
}
|
|
|
|
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
|
}
|
|
#else
|
|
struct MPVPlayerView: NSViewRepresentable {
|
|
@State private var client = MPVClient()
|
|
@State private var layer = VideoLayer()
|
|
|
|
func makeNSView(context _: Context) -> some NSView {
|
|
PlayerModel.shared.mpvBackend.client = client
|
|
|
|
let view = MPVOGLView()
|
|
|
|
if !YatteeApp.isForPreviews {
|
|
client.layer = layer
|
|
layer.client = client
|
|
|
|
view.layer = client.layer
|
|
view.wantsLayer = true
|
|
}
|
|
|
|
return view
|
|
}
|
|
|
|
func updateNSView(_: NSViewType, context _: Context) {}
|
|
}
|
|
#endif
|