mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 08:18:19 +00:00
28 lines
754 B
Swift
28 lines
754 B
Swift
|
import Defaults
|
||
|
import SwiftUI
|
||
|
|
||
|
struct AppleAVPlayerView: NSViewControllerRepresentable {
|
||
|
@EnvironmentObject<PlayerModel> private var player
|
||
|
|
||
|
@State private var controller: AppleAVPlayerViewController?
|
||
|
|
||
|
init(controller: AppleAVPlayerViewController? = nil) {
|
||
|
self.controller = controller
|
||
|
}
|
||
|
|
||
|
func makeNSViewController(context _: Context) -> AppleAVPlayerViewController {
|
||
|
if self.controller != nil {
|
||
|
return self.controller!
|
||
|
}
|
||
|
|
||
|
let controller = AppleAVPlayerViewController()
|
||
|
|
||
|
controller.playerModel = player
|
||
|
player.avPlayerBackend.controller = controller
|
||
|
|
||
|
return controller
|
||
|
}
|
||
|
|
||
|
func updateNSViewController(_: AppleAVPlayerViewController, context _: Context) {}
|
||
|
}
|