Change player size based on aspect ratio

This commit is contained in:
Arkadiusz Fal
2021-11-07 18:53:00 +01:00
parent f33319fd64
commit 76f0a1c66c
4 changed files with 29 additions and 14 deletions

View File

@@ -6,6 +6,16 @@ final class PlayerViewController: NSViewController {
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()
}