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

@@ -8,6 +8,16 @@ final class PlayerViewController: UIViewController {
var playerModel: PlayerModel!
var playerViewController = AVPlayerViewController()
var aspectRatio: Double? {
let ratio = Double(playerViewController.videoBounds.width) / Double(playerViewController.videoBounds.height)
if !ratio.isFinite {
return VideoPlayerView.defaultAspectRatio
}
return [ratio, 1.0].max()!
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)