yattee/macOS/Player.swift
Arkadiusz Fal 61a4951831 Layout and PiP improvements, new settings
- player is now a separate window on macOS
- add setting to disable pause when player is closed (fixes #40)
- add PiP settings:
  * Close PiP when starting playing other video
  * Close PiP when player is opened
  * Close PiP and open player when application
    enters foreground (iOS/tvOS) (fixes #37)
- new player placeholder when in PiP, context menu with exit option
2021-12-19 18:17:04 +01:00

28 lines
692 B
Swift

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