1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/macOS/AppleAVPlayerViewController.swift

35 lines
927 B
Swift
Raw Normal View History

2022-02-17 01:53:11 +05:30
import AVKit
import SwiftUI
2022-02-28 02:01:17 +05:30
final class AppleAVPlayerViewController: NSViewController {
2022-02-17 01:53:11 +05:30
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()!
}
override func viewDidDisappear() {
super.viewDidDisappear()
}
override func loadView() {
2022-02-28 02:01:17 +05:30
playerView.player = playerModel.avPlayerBackend.avPlayer
2022-02-17 01:53:11 +05:30
pictureInPictureDelegate.playerModel = playerModel
2022-06-25 05:09:29 +05:30
playerView.controlsStyle = .none
2022-02-17 01:53:11 +05:30
playerView.allowsPictureInPicturePlayback = true
playerView.pictureInPictureDelegate = pictureInPictureDelegate
view = playerView
}
}