Commit 361505b6 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

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

parent 4fac1cae
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#import "VLCPlaylistViewController.h" #import "VLCPlaylistViewController.h"
@interface VLCAppDelegate : UIResponder <UIApplicationDelegate> @interface VLCAppDelegate : UIResponder <UIApplicationDelegate>
{
NSURL *_tempURL;
}
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController; @property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
......
...@@ -33,12 +33,33 @@ ...@@ -33,12 +33,33 @@
{ {
if (_playlistViewController && url != nil) { if (_playlistViewController && url != nil) {
APLog(@"%@ requested %@ to be opened", sourceApplication, url); 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 YES;
} }
return NO; 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 - (void)applicationWillResignActive:(UIApplication *)application
{ {
[[MLMediaLibrary sharedMediaLibrary] applicationWillExit]; [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
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