Add naturalSize to callback

This commit is contained in:
Stanisław Chmiela 2016-04-08 11:10:22 +02:00
parent 5bb20b6f9b
commit e7cae171fb

View File

@ -263,6 +263,13 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty";
if (isnan(duration)) { if (isnan(duration)) {
duration = 0.0; 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" [_eventDispatcher sendInputEventWithName:@"onVideoLoad"
body:@{@"duration": [NSNumber numberWithFloat:duration], body:@{@"duration": [NSNumber numberWithFloat:duration],
@ -273,6 +280,10 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty";
@"canPlaySlowReverse": [NSNumber numberWithBool:_playerItem.canPlaySlowReverse], @"canPlaySlowReverse": [NSNumber numberWithBool:_playerItem.canPlaySlowReverse],
@"canStepBackward": [NSNumber numberWithBool:_playerItem.canStepBackward], @"canStepBackward": [NSNumber numberWithBool:_playerItem.canStepBackward],
@"canStepForward": [NSNumber numberWithBool:_playerItem.canStepForward], @"canStepForward": [NSNumber numberWithBool:_playerItem.canStepForward],
@"naturalSize": @{
@"width": width,
@"height": height
},
@"target": self.reactTag}]; @"target": self.reactTag}];
[self attachListeners]; [self attachListeners];