mirror of
https://github.com/yattee/yattee.git
synced 2024-12-15 23:00:32 +05:30
35 lines
940 B
Swift
35 lines
940 B
Swift
import AVKit
|
|
import SwiftUI
|
|
|
|
final class AppleAVPlayerViewController: 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()!
|
|
}
|
|
|
|
override func viewDidDisappear() {
|
|
super.viewDidDisappear()
|
|
}
|
|
|
|
override func loadView() {
|
|
playerView.player = playerModel.avPlayerBackend.avPlayer
|
|
pictureInPictureDelegate.playerModel = playerModel
|
|
|
|
playerView.allowsPictureInPicturePlayback = true
|
|
playerView.showsFullScreenToggleButton = true
|
|
|
|
playerView.pictureInPictureDelegate = pictureInPictureDelegate
|
|
|
|
view = playerView
|
|
}
|
|
}
|