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 ...@@ -143,6 +143,8 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
[[MLMediaLibrary sharedMediaLibrary] applicationWillStart]; [[MLMediaLibrary sharedMediaLibrary] applicationWillStart];
VLCMediaFileDiscoverer *discoverer = [VLCMediaFileDiscoverer sharedInstance]; VLCMediaFileDiscoverer *discoverer = [VLCMediaFileDiscoverer sharedInstance];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
discoverer.directoryPath = [searchPaths firstObject];
[discoverer addObserver:self]; [discoverer addObserver:self];
[discoverer startDiscovering]; [discoverer startDiscovering];
}; };
......
...@@ -140,8 +140,10 @@ ...@@ -140,8 +140,10 @@
[_httpServer stop]; [_httpServer stop];
return true; return true;
} }
#if TARGET_OS_IOS
// clean cache before accepting new stuff // clean cache before accepting new stuff
[self cleanCache]; [self cleanCache];
#endif
// Initialize our http server // Initialize our http server
_httpServer = [[HTTPServer alloc] init]; _httpServer = [[HTTPServer alloc] init];
......
...@@ -28,6 +28,12 @@ ...@@ -28,6 +28,12 @@
@interface VLCMediaFileDiscoverer : NSObject @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)addObserver:(id<VLCMediaFileDiscovererDelegate>)delegate;
- (void)removeObserver:(id<VLCMediaFileDiscovererDelegate>)delegate; - (void)removeObserver:(id<VLCMediaFileDiscovererDelegate>)delegate;
......
...@@ -20,7 +20,6 @@ const float MediaTimerInterval = 2.f; ...@@ -20,7 +20,6 @@ const float MediaTimerInterval = 2.f;
NSMutableArray *_observers; NSMutableArray *_observers;
dispatch_source_t _directorySource; dispatch_source_t _directorySource;
NSString *_directoryPath;
NSArray *_directoryFiles; NSArray *_directoryFiles;
NSMutableDictionary *_addedFilesMapping; NSMutableDictionary *_addedFilesMapping;
NSTimer *_addMediaTimer; NSTimer *_addMediaTimer;
...@@ -95,7 +94,12 @@ const float MediaTimerInterval = 2.f; ...@@ -95,7 +94,12 @@ const float MediaTimerInterval = 2.f;
- (void)startDiscovering - (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]; _directoryFiles = [self directoryFiles];
int const folderDescriptor = open([_directoryPath fileSystemRepresentation], O_EVTONLY); int const folderDescriptor = open([_directoryPath fileSystemRepresentation], O_EVTONLY);
...@@ -143,13 +147,6 @@ const float MediaTimerInterval = 2.f; ...@@ -143,13 +147,6 @@ const float MediaTimerInterval = 2.f;
#pragma mark - directory watcher delegate #pragma mark - directory watcher delegate
- (NSString *)directoryPath
{
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0];
return directoryPath;
}
- (void)directoryDidChange - (void)directoryDidChange
{ {
NSArray *foundFiles = [self directoryFiles]; 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