Commit 185874de authored by Felix Paul Kühne's avatar Felix Paul Kühne

album tracks: generate artwork from files if we don't have a thumbnail when asked for it

parent 318aee98
......@@ -32,6 +32,7 @@
#import "MLAlbumTrack.h"
#import "MLMediaLibrary.h"
#import "MLThumbnailerQueue.h"
#import "MLFileParserQueue.h"
NSString *kMLFileTypeMovie = @"movie";
NSString *kMLFileTypeClip = @"clip";
......@@ -282,7 +283,16 @@ NSString *kMLFileTypeAudio = @"audio";
- (UIImage *)computedThumbnail
{
return [UIImage imageWithContentsOfFile:[self thumbnailPath]];
NSString *thumbnailPath = [self thumbnailPath];
if ([[NSFileManager defaultManager] fileExistsAtPath:thumbnailPath])
return [UIImage imageWithContentsOfFile:[self thumbnailPath]];
else {
if (self.isAlbumTrack) {
if (self.albumTrack.containsArtwork)
[[MLFileParserQueue sharedFileParserQueue] addFile:self];
}
}
return nil;
}
- (void)setComputedThumbnail:(UIImage *)image
......
......@@ -169,8 +169,11 @@
albumName = file.albumTrack.album.name;
}
title = file.title;
file.computedThumbnail = [self scaleImage:[UIImage imageWithContentsOfFile:[self artworkPathForMediaItemWithTitle:title Artist:artist andAlbumName:albumName]]
toFitRect:(CGRect){CGPointZero, [[MLThumbnailerQueue sharedThumbnailerQueue] preferredThumbnailSizeForDevice]}];
if (file.computedThumbnail == nil)
file.albumTrack.containsArtwork = NO;
}
MLFileParserQueue *parserQueue = [MLFileParserQueue sharedFileParserQueue];
......@@ -178,7 +181,6 @@
[parserQueue.queue setSuspended:NO];
[parserQueue didFinishOperation:self];
_media = nil;
}
#pragma mark - audio file specific code
......
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