Skip to content

Commit

Permalink
fix(ios): Do not crash when accessLog return nil (#3549)
Browse files Browse the repository at this point in the history
accessLog method can return nil if no logging information are currently available (see https://developer.apple.com/documentation/avfoundation/avplayeritem/1388499-accesslog).
So we handle this case & do not call onVideoBandwidthUpdate

fix #3424
  • Loading branch information
gkueny authored Feb 29, 2024
1 parent ccb60c6 commit 4d4b56c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1374,9 +1374,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH

@objc
func handleAVPlayerAccess(notification: NSNotification!) {
let accessLog: AVPlayerItemAccessLog! = (notification.object as! AVPlayerItem).accessLog()
let lastEvent: AVPlayerItemAccessLogEvent! = accessLog.events.last
guard let accessLog = (notification.object as? AVPlayerItem)?.accessLog() else {
return
}

guard let lastEvent = accessLog.events.last else { return }
onVideoBandwidthUpdate?(["bitrate": lastEvent.observedBitrate, "target": reactTag])
}

Expand Down

0 comments on commit 4d4b56c

Please sign in to comment.