|
@@ -72,54 +72,6 @@
|
|
|
return sharedThumbnailCache;
|
|
|
}
|
|
|
|
|
|
-- (NSString *)_md5FromString:(NSString *)string
|
|
|
-{
|
|
|
- const char *ptr = [string UTF8String];
|
|
|
- unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
|
|
|
- CC_MD5(ptr, (unsigned int)strlen(ptr), md5Buffer);
|
|
|
- NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
|
|
|
- for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
|
|
|
- [output appendFormat:@"%02x",md5Buffer[i]];
|
|
|
-
|
|
|
- return [NSString stringWithString:output];
|
|
|
-}
|
|
|
-
|
|
|
-+ (UIImage *)thumbnailForMediaItemWithTitle:(NSString *)title Artist:(NSString*)artist andAlbumName:(NSString*)albumname
|
|
|
-{
|
|
|
- return [UIImage imageWithContentsOfFile:[[VLCThumbnailsCache sharedThumbnailCache] artworkPathForMediaItemWithTitle:title Artist:artist andAlbumName:albumname]];
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)artworkPathForMediaItemWithTitle:(NSString *)title Artist:(NSString*)artist andAlbumName:(NSString*)albumname
|
|
|
-{
|
|
|
- NSString *artworkURL;
|
|
|
- NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
|
- NSString *cacheDir = searchPaths[0];
|
|
|
- cacheDir = [cacheDir stringByAppendingFormat:@"/%@", [[NSBundle mainBundle] bundleIdentifier]];
|
|
|
-
|
|
|
- if (artist.length == 0 || albumname.length == 0) {
|
|
|
- /* Use generated hash to find art */
|
|
|
- artworkURL = [cacheDir stringByAppendingFormat:@"/art/arturl/%@/art.jpg", [self _md5FromString:title]];
|
|
|
- } else {
|
|
|
- /* Otherwise, it was cached by artist and album */
|
|
|
- artworkURL = [cacheDir stringByAppendingFormat:@"/art/artistalbum/%@/%@/art.jpg", artist, albumname];
|
|
|
- }
|
|
|
-
|
|
|
- return artworkURL;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)_getArtworkPathFromMedia:(MLFile *)file
|
|
|
-{
|
|
|
- NSString *artist, *album, *title;
|
|
|
-
|
|
|
- if (file.isAlbumTrack) {
|
|
|
- artist = file.albumTrack.artist;
|
|
|
- album = file.albumTrack.album.name;
|
|
|
- }
|
|
|
- title = file.title;
|
|
|
-
|
|
|
- return [self artworkPathForMediaItemWithTitle:title Artist:artist andAlbumName:album];
|
|
|
-}
|
|
|
-
|
|
|
+ (UIImage *)thumbnailForManagedObject:(NSManagedObject *)object
|
|
|
{
|
|
|
UIImage *thumbnail;
|
|
@@ -177,9 +129,6 @@
|
|
|
if (displayedImage)
|
|
|
return displayedImage;
|
|
|
|
|
|
- if (mediaFile.isAlbumTrack || mediaFile.isShowEpisode)
|
|
|
- displayedImage = [UIImage imageWithContentsOfFile:[self _getArtworkPathFromMedia:mediaFile]];
|
|
|
-
|
|
|
if (!displayedImage)
|
|
|
displayedImage = mediaFile.computedThumbnail;
|
|
|
|