From 91abfbde8b519e88d7eca71f9503d6a5311dc265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=87al=C4=B1k?= Date: Sun, 1 May 2016 17:41:30 +0300 Subject: [PATCH] [iOS] Added orientation to onLoad event. --- RCTVideo.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index a613ded7..7d8cdb25 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -270,9 +270,19 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; NSObject *width = @"undefined"; NSObject *height = @"undefined"; + NSString *orientation = @"undefined"; + AVAssetTrack *vT = nil; + 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]; + vT = [[_playerItem.asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; + width = [NSNumber numberWithFloat:vT.naturalSize.width]; + height = [NSNumber numberWithFloat:vT.naturalSize.height]; + CGAffineTransform txf = [vT preferredTransform]; + + if ((vT.naturalSize.width == txf.tx && vT.naturalSize.height == txf.ty) | (txf.tx == 0 && txf.ty == 0)) + orientation = @"landscape"; + else + orientation = @"portrait"; } [_eventDispatcher sendInputEventWithName:@"onVideoLoad" @@ -286,7 +296,8 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; @"canStepForward": [NSNumber numberWithBool:_playerItem.canStepForward], @"naturalSize": @{ @"width": width, - @"height": height + @"height": height, + @"orientation": orientation }, @"target": self.reactTag}];