From 7d805f13633f5a93d343ba6930ee99994423f57a Mon Sep 17 00:00:00 2001 From: Ash Mishra Date: Mon, 20 Aug 2018 11:52:06 -0700 Subject: [PATCH] Improvements to urlFilePath so that it only does a /Documents/ folder check if the file does not exist; improvements to full-screen options for iOS to default autorotate, and to respect landscape / portrait masks --- ios/RCTVideo.m | 10 ++++++---- ios/RCTVideoPlayerViewController.m | 10 ++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 455856c5..8e810b6b 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -358,15 +358,17 @@ static int const RCTVideoUnset = -1; } - (NSURL*) urlFilePath:(NSString*) filepath { - if ([filepath containsString:@"file://"] && ![filepath containsString:@"/Documents/"]) { - return [NSURL URLWithString:filepath]; + + // check if the file exists at the specified location + if ([[NSFileManager defaultManager] fileExistsAtPath:filepath]) { + return [NSURL fileURLWithPath:filepath]; } - // code to support local caching + // if no file found, check if the file exists in the Document directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* relativeFilePath = [filepath lastPathComponent]; // the file may be multiple levels below the documents directory - NSArray* fileComponents = [filepath componentsSeparatedByString:@"Documents/"]; + NSArray* fileComponents = [filepath componentsSeparatedByString:@"/Documents/"]; if (fileComponents.count>1) { relativeFilePath = [fileComponents objectAtIndex:1]; } diff --git a/ios/RCTVideoPlayerViewController.m b/ios/RCTVideoPlayerViewController.m index b79a2de2..fe8cb171 100644 --- a/ios/RCTVideoPlayerViewController.m +++ b/ios/RCTVideoPlayerViewController.m @@ -9,7 +9,7 @@ - (id)init { self = [super init]; if (self) { - self.autorotate = false; + self.autorotate = true; // autorotate should be true by default } return self; } @@ -27,12 +27,18 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations { + if ([self.preferredOrientation.lowercaseString isEqualToString:@"landscape"]) { + return UIInterfaceOrientationMaskLandscape; + } + else if ([self.preferredOrientation.lowercaseString isEqualToString:@"portrait"]) { + return UIInterfaceOrientationMaskPortrait; + } return UIInterfaceOrientationMaskAll; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { if ([self.preferredOrientation.lowercaseString isEqualToString:@"landscape"]) { - return UIInterfaceOrientationLandscapeLeft; + return UIInterfaceOrientationLandscapeRight; } else if ([self.preferredOrientation.lowercaseString isEqualToString:@"portrait"]) { return UIInterfaceOrientationPortrait;