fix(ios): ensure duration available when playing live (#3710)

* fix(ios): ensure duration is correct when starting a live playback
This commit is contained in:
Olivier Bouillet 2024-04-25 11:29:00 +02:00 committed by GitHub
parent eec125579f
commit d56b251aef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1281,8 +1281,13 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
guard let _playerItem else { return } guard let _playerItem else { return }
var duration = Float(CMTimeGetSeconds(_playerItem.asset.duration)) var duration = Float(CMTimeGetSeconds(_playerItem.asset.duration))
if duration.isNaN { if duration.isNaN || duration == 0 {
duration = 0.0 // This is a safety check for live video.
// AVPlayer report a 0 duration
duration = RCTVideoUtils.calculateSeekableDuration(_player).floatValue
if duration.isNaN {
duration = 0
}
} }
var width: Float? var width: Float?