Fix applying video player size on iOS

This commit is contained in:
Arkadiusz Fal 2022-08-17 00:35:12 +02:00
parent bda794d5ff
commit a222c722c3

View File

@ -259,7 +259,8 @@ final class MPVClient: ObservableObject {
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
guard let self = self else { return } guard let self = self else { return }
UIView.animate(withDuration: 0.2, animations: { UIView.animate(withDuration: 0.2, animations: {
let height = [self.backend.model.playerSize.height, self.backend.model.playerSize.width / self.aspectRatio].min()! let aspectRatio = self.aspectRatio > 0 && self.aspectRatio < VideoPlayerView.defaultAspectRatio ? self.aspectRatio : VideoPlayerView.defaultAspectRatio
let height = [self.backend.model.playerSize.height, self.backend.model.playerSize.width / aspectRatio].min()!
let offsetY = self.backend.model.playingFullScreen ? ((self.backend.model.playerSize.height / 2.0) - (height / 2)) : 0 let offsetY = self.backend.model.playingFullScreen ? ((self.backend.model.playerSize.height / 2.0) - (height / 2)) : 0
self.glView?.frame = CGRect(x: 0, y: offsetY, width: roundedWidth, height: height) self.glView?.frame = CGRect(x: 0, y: offsetY, width: roundedWidth, height: height)
}) { completion in }) { completion in