Skip to content

Commit

Permalink
fix(ios): ensure duration available when playing live (#3710)
Browse files Browse the repository at this point in the history
* fix(ios): ensure duration is correct when starting a live playback
  • Loading branch information
freeboub authored Apr 25, 2024
1 parent eec1255 commit d56b251
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit d56b251

Please sign in to comment.