Commit 5788eb66 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

media discoverer: add support for custom monitoring locations

parent b7eab733
......@@ -143,6 +143,8 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
[[MLMediaLibrary sharedMediaLibrary] applicationWillStart];
VLCMediaFileDiscoverer *discoverer = [VLCMediaFileDiscoverer sharedInstance];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
discoverer.directoryPath = [searchPaths firstObject];
[discoverer addObserver:self];
[discoverer startDiscovering];
};
......
......@@ -140,8 +140,10 @@
[_httpServer stop];
return true;
}
#if TARGET_OS_IOS
// clean cache before accepting new stuff
[self cleanCache];
#endif
// Initialize our http server
_httpServer = [[HTTPServer alloc] init];
......
......@@ -28,6 +28,12 @@
@interface VLCMediaFileDiscoverer : NSObject
/**
* the path the discoverer will monitor
* \note _MUST_ be set before starting the discovery
*/
@property (readwrite, retain, nonatomic) NSString *directoryPath;
- (void)addObserver:(id<VLCMediaFileDiscovererDelegate>)delegate;
- (void)removeObserver:(id<VLCMediaFileDiscovererDelegate>)delegate;
......
......@@ -20,7 +20,6 @@ const float MediaTimerInterval = 2.f;
NSMutableArray *_observers;
dispatch_source_t _directorySource;
NSString *_directoryPath;
NSArray *_directoryFiles;
NSMutableDictionary *_addedFilesMapping;
NSTimer *_addMediaTimer;
......@@ -95,7 +94,12 @@ const float MediaTimerInterval = 2.f;
- (void)startDiscovering
{
_directoryPath = [self directoryPath];
if (!_directoryPath) {
APLog(@"file discovery failed, no path was set");
return;
} else
APLog(@"will discover files in path: '%@'", _directoryPath);
_directoryFiles = [self directoryFiles];
int const folderDescriptor = open([_directoryPath fileSystemRepresentation], O_EVTONLY);
......@@ -143,13 +147,6 @@ const float MediaTimerInterval = 2.f;
#pragma mark - directory watcher delegate
- (NSString *)directoryPath
{
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0];
return directoryPath;
}
- (void)directoryDidChange
{
NSArray *foundFiles = [self directoryFiles];
......
Supports Markdown
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