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

@ -264,6 +264,13 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty";
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],
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)],
@ -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];