From d56b251aef6d4ca1708c7bbada15016efbf12caf Mon Sep 17 00:00:00 2001 From: Olivier Bouillet <62574056+freeboub@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:29:00 +0200 Subject: [PATCH] fix(ios): ensure duration available when playing live (#3710) * fix(ios): ensure duration is correct when starting a live playback --- ios/Video/RCTVideo.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 8cdd66ae..d8f7f2a1 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -1281,8 +1281,13 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH guard let _playerItem else { return } var duration = Float(CMTimeGetSeconds(_playerItem.asset.duration)) - if duration.isNaN { - duration = 0.0 + if duration.isNaN || duration == 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?