2021-09-25 08:18:22 +00:00
|
|
|
import Defaults
|
2021-07-18 22:32:46 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct Player: NSViewControllerRepresentable {
|
2021-10-05 20:20:09 +00:00
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
2021-07-18 22:32:46 +00:00
|
|
|
|
2021-12-19 17:17:04 +00:00
|
|
|
@State private var controller: PlayerViewController?
|
2021-10-05 20:20:09 +00:00
|
|
|
|
|
|
|
init(controller: PlayerViewController? = nil) {
|
|
|
|
self.controller = controller
|
|
|
|
}
|
2021-09-25 08:18:22 +00:00
|
|
|
|
2021-07-18 22:32:46 +00:00
|
|
|
func makeNSViewController(context _: Context) -> PlayerViewController {
|
2021-10-05 20:20:09 +00:00
|
|
|
if self.controller != nil {
|
|
|
|
return self.controller!
|
|
|
|
}
|
2021-08-22 19:13:33 +00:00
|
|
|
|
2021-10-05 20:20:09 +00:00
|
|
|
let controller = PlayerViewController()
|
2021-09-25 08:18:22 +00:00
|
|
|
|
2021-10-05 20:20:09 +00:00
|
|
|
controller.playerModel = player
|
2021-10-13 22:10:29 +00:00
|
|
|
player.controller = controller
|
2021-07-18 22:32:46 +00:00
|
|
|
|
|
|
|
return controller
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateNSViewController(_: PlayerViewController, context _: Context) {}
|
|
|
|
}
|