Commit 5bed2d3a authored by Pierre's avatar Pierre

Support thumbnail time out.

parent 71f0ca86
......@@ -49,6 +49,7 @@ extern NSString *kMLFileTypeTVShowEpisode;
@property (nonatomic, assign) BOOL isSafe;
@property (nonatomic, assign) BOOL isBeingParsed;
@property (nonatomic, assign) BOOL thumbnailTimeouted;
/**
* the data in this object are about to be put on screen
......
......@@ -24,6 +24,7 @@
- (NSFetchRequest *)fetchRequestForEntity:(NSString *)entity;
- (id)createObjectForEntity:(NSString *)entity;
- (void)applicationWillStart;
- (void)applicationWillExit;
- (void)save;
......
......@@ -139,6 +139,21 @@ NSString *kMLFileTypeTVShowEpisode = @"tvShowEpisode";
[self willChangeValueForKey:@"isBeingParsed"];
}
- (BOOL)thumbnailTimeouted
{
[self willAccessValueForKey:@"thumbnailTimeouted"];
NSNumber *ret = [self primitiveValueForKey:@"thumbnailTimeouted"];
[self didAccessValueForKey:@"thumbnailTimeouted"];
return [ret boolValue];
}
- (void)setThumbnailTimeouted:(BOOL)thumbnailTimeouted
{
[self willChangeValueForKey:@"thumbnailTimeouted"];
[self setPrimitiveValue:[NSNumber numberWithBool:thumbnailTimeouted] forKey:@"thumbnailTimeouted"];
[self willChangeValueForKey:@"thumbnailTimeouted"];
}
- (void)willDisplay
{
......
......@@ -83,6 +83,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
int directory = NSLibraryDirectory;
NSArray *paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
NSString *directoryPath = [paths objectAtIndex:0];
[[NSFileManager defaultManager] removeItemAtPath:directoryPath error:nil];
return directoryPath;
}
......@@ -612,8 +613,6 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
file.isOnDisk = [NSNumber numberWithBool:exists];
}
[[MLCrashPreventer sharedPreventer] markCrasherFiles];
// Get the file to parse
request = [self fetchRequestForEntity:@"File"];
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && tracks.@count == 0"]];
......@@ -677,6 +676,11 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
[[MLCrashPreventer sharedPreventer] cancelAllFileParse];
}
- (void)applicationWillStart
{
[[MLCrashPreventer sharedPreventer] markCrasherFiles];
}
- (void)libraryDidDisappear
{
// Stop expansive work
......
......@@ -59,18 +59,28 @@
[self performSelectorOnMainThread:@selector(fetchThumbnail) withObject:nil waitUntilDone:YES];
}
- (void)mediaThumbnailer:(VLCMediaThumbnailer *)mediaThumbnailer didFinishThumbnail:(CGImageRef)thumbnail
- (void)endThumbnailing
{
mediaThumbnailer.delegate = nil;
MLLog(@"Finished thumbnail for %@", self.file.title);
self.file.computedThumbnail = UIImagePNGRepresentation([UIImage imageWithCGImage:thumbnail]);
[[MLCrashPreventer sharedPreventer] didParseFile:self.file];
MLThumbnailerQueue *thumbnailer = [MLThumbnailerQueue sharedThumbnailerQueue];
[thumbnailer.queue setSuspended:NO];
[thumbnailer didFinishOperation:self];
[self release];
}
- (void)mediaThumbnailer:(VLCMediaThumbnailer *)mediaThumbnailer didFinishThumbnail:(CGImageRef)thumbnail
{
mediaThumbnailer.delegate = nil;
MLLog(@"Finished thumbnail for %@", self.file.title);
self.file.computedThumbnail = UIImagePNGRepresentation([UIImage imageWithCGImage:thumbnail]);
[self endThumbnailing];
}
- (void)mediaThumbnailerDidTimeOut:(VLCMediaThumbnailer *)mediaThumbnailer
{
self.file.thumbnailTimeouted = YES;
[self endThumbnailing];
}
@end
@implementation MLThumbnailerQueue
......
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