fix(ios): ensure onBandwidthUpdate is reported only when value change (#4149)
* fix(ios): ensure onBandwidthUpdate is reported only when value change * chore: fix PodFile.lock
This commit is contained in:
@@ -63,6 +63,8 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
private var _presentingViewController: UIViewController?
|
||||
private var _startPosition: Float64 = -1
|
||||
private var _showNotificationControls = false
|
||||
// Buffer last bitrate value received. Initialized to -2 to ensure -1 (sometimes reported by AVPlayer) is not missed
|
||||
private var _lastBitrate = -2.0
|
||||
private var _pictureInPictureEnabled = false {
|
||||
didSet {
|
||||
#if os(iOS)
|
||||
@@ -1662,9 +1664,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
guard let accessLog = (notification.object as? AVPlayerItem)?.accessLog() else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let lastEvent = accessLog.events.last else { return }
|
||||
onVideoBandwidthUpdate?(["bitrate": lastEvent.indicatedBitrate, "target": reactTag])
|
||||
if lastEvent.indicatedBitrate != _lastBitrate {
|
||||
_lastBitrate = lastEvent.indicatedBitrate
|
||||
onVideoBandwidthUpdate?(["bitrate": _lastBitrate, "target": reactTag])
|
||||
}
|
||||
}
|
||||
|
||||
func handleTracksChange(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<[AVPlayerItemTrack]>) {
|
||||
|
Reference in New Issue
Block a user