/// <summary> /// Returns a cover art image for the specified track. /// </summary> /// <param name="trackInfo"> /// An object contating data of currently playing track. /// </param> /// <param name="concreteRule"> /// A rule that should be used to search for cover art image. /// </param> /// <returns>Result of cover art image search.</returns> public Bitmap GetBitmap(TrackInfo trackInfo, FindRule concreteRule) { Bitmap result = null; try { if (!trackInfo.IsStream) { var n = new LastFmLib.API20.Album.AlbumGetInfo(trackInfo.Artist, trackInfo.Album); n.Start(); if (n.Succeeded) { if (n.Result.HasAnyImage) { result = n.Result.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Original); if (result == null) { if (n.Result.ImageExtraLarge != null) result = n.Result.DownloadImage(LastFmLib.API20.modEnums.ImageSize.ExtraLarge); else if (n.Result.ImageLarge != null) result = n.Result.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Large); else if (n.Result.ImageMedium != null) result = n.Result.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Medium); else if (n.Result.ImageSmall != null) result = n.Result.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Small); } } } } else { // get bitmap for radio String[] s = String.IsNullOrEmpty(trackInfo.Artist) ? trackInfo.Title.Split('-') : new string[] { trackInfo.Artist, trackInfo.Title }; if (s.Length > 1) { var n = new LastFmLib.API20.Tracks.TrackGetInfo(s[0].Trim(), s[1].Trim()); n.Start(); if (n.Succeeded) { var info = (TrackInformation)n.Result; if (info.Album != null && info.Album.HasAnyImage) { result = info.Album.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Original); if (result == null) { if (info.Album.ImageExtraLarge != null) result = info.Album.DownloadImage(LastFmLib.API20.modEnums.ImageSize.ExtraLarge); else if (info.Album.ImageLarge != null) result = info.Album.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Large); else if (n.Result.ImageMedium != null) result = info.Album.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Medium); else if (n.Result.ImageSmall != null) result = info.Album.DownloadImage(LastFmLib.API20.modEnums.ImageSize.Small); } } } } } } catch (Exception ex) { #if DEBUG MessageBox.Show(ex.ToString(), "LastFm Error", MessageBoxButton.OK, MessageBoxImage.Error); #endif } return result; }
public Bitmap GetBitmap(IAimpPlayer player, FindRule concreteRule) { player.AlbumArtManager.Completed += (sender, args) => { Result = args.CoverImage; _resetEvent.Set(); }; player.AlbumArtManager.GetImage(player.CurrentFileInfo, AimpFingCovertArtType.None, null); _resetEvent.WaitOne(new TimeSpan(0, 0, 0, 20)); return Result; }
public Bitmap GetBitmap(IAimpPlayer player, FindRule concreteRule) { return GetBitmap(new TrackInfo(player), concreteRule); }
/// <summary> /// Returns a cover art image for the specified track. /// </summary> /// <param name="trackInfo"> /// An object contating data of currently playing track. /// </param> /// <param name="concreteRule"> /// A rule that should be used to search for cover art image. /// </param> /// <returns>Result of cover art image search.</returns> public Bitmap GetBitmap(TrackInfo trackInfo, FindRule concreteRule) { throw new System.NotImplementedException(); }