private byte[] GetExternalArtwork(string filename, int size) { byte[] artwork = null; artwork = IndexerUtils.GetExternalArtwork(filename, size, size); return(artwork); }
private byte[] GetExternalArtwork(string filename, int size) { byte[] artwork = null; artwork = IndexerUtils.GetExternalArtwork(filename, size, size); if (artwork != null) { this.cachedArtwork = new Tuple <string, byte[]>(filename, artwork); } return(artwork); }
public async Task <byte[]> GetArtworkAsync(string path) { byte[] artwork = null; await Task.Run(async() => { lock (this.cachedArtworkLock) { // First, check if artwork for this path has been asked recently. if (this.cachedArtwork != null && this.cachedArtwork.Item1.ToSafePath() == path.ToSafePath()) { if (this.cachedArtwork.Item2 != null) { artwork = this.cachedArtwork.Item2; } } if (artwork == null) { // If no cached artwork was found, try to load embedded artwork. IFileMetadata fmd = this.GetFileMetadata(path); if (fmd.ArtworkData.Value != null) { artwork = fmd.ArtworkData.Value; this.cachedArtwork = new Tuple <string, byte[]>(path, artwork); } } if (artwork == null) { // If no embedded artwork was found, try to find external artwork. artwork = IndexerUtils.GetExternalArtwork(path); if (artwork != null) { this.cachedArtwork = new Tuple <string, byte[]>(path, artwork); } } if (artwork == null) { // If no embedded artwork was found, try to find album artwork. Track track = this.trackRepository.GetTrack(path); Album album = track != null ? this.albumRepository.GetAlbum(track.AlbumID) : null; if (album != null) { string artworkPath = this.cacheService.GetCachedArtworkPath((string)album.ArtworkID); if (!string.IsNullOrEmpty(artworkPath)) { artwork = ImageUtils.Image2ByteArray(artworkPath); } if (artwork != null) { this.cachedArtwork = new Tuple <string, byte[]>(path, artwork); } } } } }); return(artwork); }