Browse Source

Query user if s/he'd like to download or play ftp/http/https streams when requested from 3rd party apps (close #11147)

Felix Paul Kühne 11 years ago
parent
commit
4cbb7f8a37
2 changed files with 15 additions and 2 deletions
  1. BIN
      Resources/en.lproj/Localizable.strings
  2. 15 2
      Sources/VLCAppDelegate.m

BIN
Resources/en.lproj/Localizable.strings


+ 15 - 2
Sources/VLCAppDelegate.m

@@ -26,6 +26,7 @@
 #import "VLCHTTPUploaderController.h"
 #import "VLCMenuTableViewController.h"
 #import "BWQuincyManager.h"
+#import "VLCAlertView.h"
 
 @interface VLCAppDelegate () <PAPasscodeViewControllerDelegate, VLCMediaFileDiscovererDelegate, BWQuincyManagerDelegate> {
     PAPasscodeViewController *_passcodeLockController;
@@ -118,7 +119,7 @@
             NSError *theError;
             [[NSFileManager defaultManager] moveItemAtURL:url toURL:destinationURL error:&theError];
             if (theError.code != noErr)
-                APLog(@"saving the file failed (%li): %@", theError.code, theError.localizedDescription);
+                APLog(@"saving the file failed (%li): %@", (long)theError.code, theError.localizedDescription);
 
             [self updateMediaList];
         } else {
@@ -139,7 +140,19 @@
                 }
             }
             [self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
-            [self openMovieFromURL:url];
+
+            NSString *scheme = url.scheme;
+            if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"ftp"]) {
+                VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"OPEN_STREAM_OR_DOWNLOAD", @"") message:url.absoluteString cancelButtonTitle:NSLocalizedString(@"BUTTON_DOWNLOAD", @"") otherButtonTitles:@[NSLocalizedString(@"BUTTON_PLAY", @"")]];
+                alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
+                    if (cancelled)
+                        [[self downloadViewController] addURLToDownloadList:url fileNameOfMedia:nil];
+                    else
+                        [self openMovieFromURL:url];
+                };
+                [alert show];
+            } else
+                [self openMovieFromURL:url];
         }
         return YES;
     }