فهرست منبع

thumbnail cache: remove very bad had hack to handle album art as this is correctly done by MLKit now

Felix Paul Kühne 10 سال پیش
والد
کامیت
5d00ca4090
3فایلهای تغییر یافته به همراه1 افزوده شده و 54 حذف شده
  1. 1 1
      Sources/VLCPlaybackController.m
  2. 0 2
      Sources/VLCThumbnailsCache.h
  3. 0 51
      Sources/VLCThumbnailsCache.m

+ 1 - 1
Sources/VLCPlaybackController.m

@@ -769,7 +769,7 @@
             _albumName = metaDict[VLCMetaInformationAlbum];
             trackNumber = [metaDict[VLCMetaInformationTrackNumber] numberValue];
             if (_mediaIsAudioOnly)
-                _artworkImage = [VLCThumbnailsCache thumbnailForMediaItemWithTitle:_title Artist:_artist andAlbumName:_albumName];
+                _artworkImage = [VLCThumbnailsCache thumbnailForManagedObject:item];
         }
     }
 

+ 0 - 2
Sources/VLCThumbnailsCache.h

@@ -16,8 +16,6 @@
 
 + (UIImage *)thumbnailForManagedObject:(NSManagedObject *)object;
 
-+ (UIImage *)thumbnailForMediaItemWithTitle:(NSString *)title Artist:(NSString*)artist andAlbumName:(NSString*)albumname;
-
 + (UIImage *)thumbnailForManagedObject:(NSManagedObject *)object toFitRect:(CGRect)rect shouldReplaceCache:(BOOL)replaceCache;
 
 @end

+ 0 - 51
Sources/VLCThumbnailsCache.m

@@ -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;