fix(ios): Do not crash when accessLog return nil (#3549)
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 https://github.com/react-native-video/react-native-video/issues/3424
This commit is contained in:
parent
ccb60c6dd3
commit
4d4b56c05d
@ -1374,9 +1374,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
|
|
||||||
@objc
|
@objc
|
||||||
func handleAVPlayerAccess(notification: NSNotification!) {
|
func handleAVPlayerAccess(notification: NSNotification!) {
|
||||||
let accessLog: AVPlayerItemAccessLog! = (notification.object as! AVPlayerItem).accessLog()
|
guard let accessLog = (notification.object as? AVPlayerItem)?.accessLog() else {
|
||||||
let lastEvent: AVPlayerItemAccessLogEvent! = accessLog.events.last
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let lastEvent = accessLog.events.last else { return }
|
||||||
onVideoBandwidthUpdate?(["bitrate": lastEvent.observedBitrate, "target": reactTag])
|
onVideoBandwidthUpdate?(["bitrate": lastEvent.observedBitrate, "target": reactTag])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user