From e7cae171fba3e8c82fb45545187a0a54ccacaaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 8 Apr 2016 11:10:22 +0200 Subject: [PATCH] Add naturalSize to callback --- RCTVideo.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/RCTVideo.m b/RCTVideo.m index 3c0fa291..5cf83d27 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -263,6 +263,13 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; if (isnan(duration)) { duration = 0.0; } + + NSObject *width = @"undefined"; + NSObject *height = @"undefined"; + if ([_playerItem.asset tracksWithMediaType:AVMediaTypeVideo].count > 0) { + width = [NSNumber numberWithFloat:[_playerItem.asset tracksWithMediaType:AVMediaTypeVideo][0].naturalSize.width]; + height = [NSNumber numberWithFloat:[_playerItem.asset tracksWithMediaType:AVMediaTypeVideo][0].naturalSize.height]; + } [_eventDispatcher sendInputEventWithName:@"onVideoLoad" body:@{@"duration": [NSNumber numberWithFloat:duration], @@ -273,6 +280,10 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; @"canPlaySlowReverse": [NSNumber numberWithBool:_playerItem.canPlaySlowReverse], @"canStepBackward": [NSNumber numberWithBool:_playerItem.canStepBackward], @"canStepForward": [NSNumber numberWithBool:_playerItem.canStepForward], + @"naturalSize": @{ + @"width": width, + @"height": height + }, @"target": self.reactTag}]; [self attachListeners];