IOS bandwidth reporting

IOS bandwidth reporting
This commit is contained in:
sridhar 2018-09-19 17:58:49 +05:30
parent a1a0ca648c
commit b256f2d4d8
3 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,7 @@
@property (nonatomic, copy) RCTBubblingEventBlock onVideoBuffer;
@property (nonatomic, copy) RCTBubblingEventBlock onVideoError;
@property (nonatomic, copy) RCTBubblingEventBlock onVideoProgress;
@property (nonatomic, copy) RCTBubblingEventBlock onBandwidthUpdate;
@property (nonatomic, copy) RCTBubblingEventBlock onVideoSeek;
@property (nonatomic, copy) RCTBubblingEventBlock onVideoEnd;
@property (nonatomic, copy) RCTBubblingEventBlock onTimedMetadata;

View File

@ -592,8 +592,10 @@ static int const RCTVideoUnset = -1;
- (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);
if (self.onBandwidthUpdate) {
self.onBandwidthUpdate(@{@"bitrateEstimate": [NSNumber numberWithFloat:(lastEvent.observedBitrate/1000)]});
}
}
- (void)playbackStalled:(NSNotification *)notification

View File

@ -44,6 +44,7 @@ RCT_EXPORT_VIEW_PROPERTY(onVideoLoad, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoBuffer, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoError, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoProgress, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onBandwidthUpdate, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoSeek, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoEnd, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onTimedMetadata, RCTBubblingEventBlock);