1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 14:20:32 +05:30
yattee/macOS/AVPlayerView.swift
Arkadiusz Fal 31a28a7cbd Hello, mpv! 🎉
2022-10-27 18:03:57 +02:00

28 lines
708 B
Swift

import Defaults
import SwiftUI
struct AVPlayerView: NSViewControllerRepresentable {
@EnvironmentObject<PlayerModel> private var player
@State private var controller: AVPlayerViewController?
init(controller: AVPlayerViewController? = nil) {
self.controller = controller
}
func makeNSViewController(context _: Context) -> AVPlayerViewController {
if self.controller != nil {
return self.controller!
}
let controller = AVPlayerViewController()
controller.playerModel = player
player.controller = controller
return controller
}
func updateNSViewController(_: AVPlayerViewController, context _: Context) {}
}