1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-12 21:30:32 +05:30
yattee/macOS/PlayerViewController.swift
2024-02-02 11:16:27 +01:00

35 lines
906 B
Swift

import AVKit
import SwiftUI
final class PlayerViewController: NSViewController {
var playerModel: PlayerModel!
var playerView = AVPlayerView()
var pictureInPictureDelegate = PictureInPictureDelegate()
var aspectRatio: Double? {
let ratio = Double(playerView.videoBounds.width) / Double(playerView.videoBounds.height)
if !ratio.isFinite {
return VideoPlayerView.defaultAspectRatio
}
return [ratio, 1.0].max()!
}
func viewDidDisappear() {
super.viewDidDisappear()
}
override func loadView() {
playerView.player = playerModel.player
pictureInPictureDelegate.playerModel = playerModel
playerView.allowsPictureInPicturePlayback = true
playerView.showsFullScreenToggleButton = true
playerView.pictureInPictureDelegate = pictureInPictureDelegate
view = playerView
}
}