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

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

parent 4fac1cae
......@@ -10,6 +10,9 @@
#import "VLCPlaylistViewController.h"
@interface VLCAppDelegate : UIResponder <UIApplicationDelegate>
{
NSURL *_tempURL;
}
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
......
......@@ -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];
......
B"CHOOSE_AUDIO_TRACK"="Audiospur wählen";
......
B"CHOOSE_AUDIO_TRACK"="Choose Audio Track";
......
B"CHOOSE_AUDIO_TRACK"="Choisir Piste Audio";
......
B"CHOOSE_AUDIO_TRACK"="Выберите аудио поток";
......
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