Skip to content

Commit

Permalink
fix(iOS): sometimes aspect ratio is invalid (#3821)
Browse files Browse the repository at this point in the history
* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* fix: invert aspect ratio evaluation to find video height / width
  • Loading branch information
freeboub authored May 22, 2024
1 parent bb2404f commit dac0985
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1383,12 +1383,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
var orientation = "undefined"

let tracks = await RCTVideoAssetsUtils.getTracks(asset: _playerItem.asset, withMediaType: .video)
if let videoTrack = tracks?.first {
width = Float(videoTrack.naturalSize.width)
height = Float(videoTrack.naturalSize.height)
} else if _playerItem.presentationSize.height != 0.0 {
width = Float(_playerItem.presentationSize.width)
height = Float(_playerItem.presentationSize.height)
var presentationSize = _playerItem.presentationSize
if presentationSize.height != 0.0 {
width = Float(presentationSize.width)
height = Float(presentationSize.height)
} else if let videoTrack = tracks?.first {
let naturalSize = videoTrack.naturalSize
width = Float(naturalSize.width)
height = Float(naturalSize.height)
}
orientation = width > height ? "landscape" : width == height ? "square" : "portrait"

Expand Down

0 comments on commit dac0985

Please sign in to comment.