From a1a0ca648c5e8ddf49da4f999edc6b35ffbde93a Mon Sep 17 00:00:00 2001 From: sridhar Date: Tue, 18 Sep 2018 20:09:32 +0530 Subject: [PATCH] bandwidth report for IOS bandwidth report for IOS --- ios/RCTVideo.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index f5fc6125..2d5030ca 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -578,6 +578,22 @@ static int const RCTVideoUnset = -1; selector:@selector(playbackStalled:) name:AVPlayerItemPlaybackStalledNotification object:nil]; + + [[NSNotificationCenter defaultCenter] removeObserver:self + name:AVPlayerItemNewAccessLogEntryNotification + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(handleAVPlayerAccess:) + name:AVPlayerItemNewAccessLogEntryNotification + object:nil]; + +} + +- (void)handleAVPlayerAccess:(NSNotification *)notification { + AVPlayerItemAccessLog *accessLog = [((AVPlayerItem *)notification.object) accessLog]; + AVPlayerItemAccessLogEvent *lastEvent = accessLog.events.lastObject; + float lastEventNumber = lastEvent.indicatedBitrate; + RCTLog(@"Switch indicatedBitrate from: %f to: %f", lastEvent.observedBitrate, lastEvent.indicatedBitrate); } - (void)playbackStalled:(NSNotification *)notification