Commit 00795441 authored by Ulrich Trampe's avatar Ulrich Trampe Committed by Felix Paul Kühne

VLC for iOS improved x-callback-url implementation

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent af363eca
......@@ -142,6 +142,7 @@
NSString *action = [url.path stringByReplacingOccurrencesOfString:@"/" withString:@""];
NSURL *movieURL = nil;
NSURL *successCallback = nil;
NSString *fileName = nil;
for (NSString *entry in [url.query componentsSeparatedByString:@"&"]) {
NSArray *keyvalue = [entry componentsSeparatedByString:@"="];
if (keyvalue.count < 2) continue;
......@@ -150,6 +151,9 @@
if ([key isEqualToString:@"url"]) {
movieURL = [NSURL URLWithString:value];
}
else if ([key isEqualToString:@"filename"]) {
fileName = value;
}
else if ([key isEqualToString:@"x-success"]) {
successCallback = [NSURL URLWithString:value];
}
......@@ -157,6 +161,9 @@
if ([action isEqualToString:@"stream"] && movieURL) {
[self openMovieFromURL:movieURL successCallback:successCallback];
}
else if ([action isEqualToString:@"download"] && movieURL) {
[self downloadMovieFromURL:movieURL fileNameOfMedia:fileName];
}
} else {
NSString *receivedUrl = [url absoluteString];
if ([receivedUrl length] > 6) {
......@@ -184,7 +191,7 @@
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"OPEN_STREAM_OR_DOWNLOAD", nil) message:url.absoluteString cancelButtonTitle:NSLocalizedString(@"BUTTON_DOWNLOAD", nil) otherButtonTitles:@[NSLocalizedString(@"BUTTON_PLAY", nil)]];
alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
if (cancelled)
[[self downloadViewController] addURLToDownloadList:url fileNameOfMedia:nil];
[self downloadMovieFromURL:url fileNameOfMedia:nil];
else
[self openMovieFromURL:url];
};
......@@ -411,6 +418,17 @@
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
#pragma mark - download handling
- (void)downloadMovieFromURL:(NSURL *)url
fileNameOfMedia:(NSString *)fileName
{
[self.downloadViewController addURLToDownloadList:url fileNameOfMedia:fileName];
// select Downloads menu item and reveal corresponding viewcontroller
[self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:1] animated:NO scrollPosition:UITableViewScrollPositionNone];
}
#pragma mark - playback view handling
- (void)openMediaFromManagedObject:(NSManagedObject *)mediaObject
......
......@@ -905,12 +905,12 @@
- (IBAction)closePlayback:(id)sender
{
[self setControlsHidden:NO animated:NO];
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
// switch back to the caller when user presses "Done"
if (self.successCallback && [sender isKindOfClass:[UIBarButtonItem class]]) {
[[UIApplication sharedApplication] openURL:self.successCallback];
}
[self.navigationController dismissViewControllerAnimated:YES completion:^{
// switch back to the caller when user presses "Done"
if (self.successCallback && [sender isKindOfClass:[UIBarButtonItem class]]) {
[[UIApplication sharedApplication] openURL:self.successCallback];
}
}];
}
- (IBAction)positionSliderAction:(UISlider *)sender
......
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