mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Fixes for MPV in macOS
This commit is contained in:
27
macOS/AppleAVPlayerView.swift
Normal file
27
macOS/AppleAVPlayerView.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
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) {}
|
||||
}
|
Reference in New Issue
Block a user