瀏覽代碼

add the ability to store files from 3rd parties in the media library (close #8629)

Felix Paul Kühne 12 年之前
父節點
當前提交
361505b6fc

+ 3 - 0
AspenProject/VLCAppDelegate.h

@@ -10,6 +10,9 @@
 #import "VLCPlaylistViewController.h"
 
 @interface VLCAppDelegate : UIResponder <UIApplicationDelegate>
+{
+    NSURL *_tempURL;
+}
 
 @property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
 

+ 22 - 1
AspenProject/VLCAppDelegate.m

@@ -33,12 +33,33 @@
 {
     if (_playlistViewController && url != nil) {
         APLog(@"%@ requested %@ to be opened", sourceApplication, url);
-        [_playlistViewController openMovieFromURL:url];
+
+        if (url.isFileURL) {
+            UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"SAVE_FILE", @"") message:[NSString stringWithFormat:NSLocalizedString(@"SAVE_FILE_LONG", @""), url.lastPathComponent] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_SAVE", @""), nil];
+            _tempURL = url;
+            [alert show];
+        } else
+            [_playlistViewController openMovieFromURL:url];
         return YES;
     }
     return NO;
 }
 
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+    if (buttonIndex == 1) {
+        NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+        NSString *directoryPath = [searchPaths objectAtIndex:0];
+        NSURL *destinationURL = [NSURL URLWithString:[NSString stringWithFormat:@"file://%@/%@", directoryPath, _tempURL.lastPathComponent]];
+        NSError *theError;
+        [[NSFileManager defaultManager] copyItemAtURL:_tempURL toURL:destinationURL error:&theError];
+
+        [self updateMediaList];
+    }
+
+    [_playlistViewController openMovieFromURL:_tempURL];
+}
+
 - (void)applicationWillResignActive:(UIApplication *)application
 {
     [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];

二進制
Resources/de.lproj/Localizable.strings


二進制
Resources/en.lproj/Localizable.strings


二進制
Resources/fr.lproj/Localizable.strings


二進制
Resources/ru.lproj/Localizable.strings