Commit b850111a authored by Carola's avatar Carola

VLCAppDelegate: play files that come from the Files App and within VLC

parent cf7fa8ab
...@@ -312,14 +312,21 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -312,14 +312,21 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if (url.isFileURL) { if (url.isFileURL) {
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0]; NSString *directoryPath = searchPaths.firstObject;
NSURL *destinationURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", directoryPath, url.lastPathComponent]]; NSURL *destinationURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", directoryPath, url.lastPathComponent]];
NSError *theError; NSError *theError;
NSFileManager *manager = [NSFileManager defaultManager];
[[NSFileManager defaultManager] moveItemAtURL:url toURL:destinationURL error:&theError]; [[NSFileManager defaultManager] moveItemAtURL:url toURL:destinationURL error:&theError];
if (theError.code != noErr) if (theError.code != noErr)
APLog(@"saving the file failed (%li): %@", (long)theError.code, theError.localizedDescription); APLog(@"saving the file failed (%li): %@", (long)theError.code, theError.localizedDescription);
[[VLCMediaFileDiscoverer sharedInstance] updateMediaList]; [[VLCMediaFileDiscoverer sharedInstance] updateMediaList];
NSURLRelationship relationship;
[manager getRelationship:&relationship ofDirectoryAtURL:[NSURL fileURLWithPath:directoryPath] toItemAtURL:url error:&theError];
if (relationship == NSURLRelationshipContains) {
[self playWithURL:url successCallback:nil errorCallback:nil];
}
} else if ([url.scheme isEqualToString:@"vlc-x-callback"] || [url.host isEqualToString:@"x-callback-url"]) { } else if ([url.scheme isEqualToString:@"vlc-x-callback"] || [url.host isEqualToString:@"x-callback-url"]) {
// URL confirmes to the x-callback-url specification // URL confirmes to the x-callback-url specification
// vlc-x-callback://x-callback-url/action?param=value&x-success=callback // vlc-x-callback://x-callback-url/action?param=value&x-success=callback
...@@ -345,7 +352,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -345,7 +352,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
errorCallback = [NSURL URLWithString:value]; errorCallback = [NSURL URLWithString:value];
} }
if ([action isEqualToString:@"stream"] && movieURL) { if ([action isEqualToString:@"stream"] && movieURL) {
[self playWithUrl:movieURL successCallback:successCallback errorCallback:errorCallback]; [self playWithURL:movieURL successCallback:successCallback errorCallback:errorCallback];
} }
else if ([action isEqualToString:@"download"] && movieURL) { else if ([action isEqualToString:@"download"] && movieURL) {
[self downloadMovieFromURL:movieURL fileNameOfMedia:fileName]; [self downloadMovieFromURL:movieURL fileNameOfMedia:fileName];
...@@ -380,12 +387,12 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -380,12 +387,12 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if (cancelled) if (cancelled)
[self downloadMovieFromURL:url fileNameOfMedia:nil]; [self downloadMovieFromURL:url fileNameOfMedia:nil];
else { else {
[self playWithUrl:url successCallback:nil errorCallback:nil]; [self playWithURL:url successCallback:nil errorCallback:nil];
} }
}; };
[alert show]; [alert show];
} else { } else {
[self playWithUrl:url successCallback:nil errorCallback:nil]; [self playWithURL:url successCallback:nil errorCallback:nil];
} }
} }
return YES; return YES;
...@@ -496,7 +503,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -496,7 +503,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
} }
#pragma mark - playback #pragma mark - playback
- (void)playWithUrl:(NSURL *)url successCallback:(NSURL *)successCallback errorCallback:(NSURL *)errorCallback - (void)playWithURL:(NSURL *)url successCallback:(NSURL *)successCallback errorCallback:(NSURL *)errorCallback
{ {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
vpc.fullscreenSessionRequested = YES; vpc.fullscreenSessionRequested = YES;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment