private async static Task <BitmapImage> GetCover(TagLib.File tags, string artist, string title) { if (tags.Tag.Pictures.Length > 0) { var picture = tags.Tag.Pictures[0].Data; using (var ms = new System.IO.MemoryStream(picture.Data)) { BitmapImage ret = new BitmapImage(); ret.BeginInit(); ret.StreamSource = ms; ret.DecodePixelWidth = 300; ret.CacheOption = BitmapCacheOption.OnLoad; ret.EndInit(); ret.Freeze(); return(ret); } } else { var bytes = await iTunesCoverDownloader.GetCoverFor($"{artist} - {title}"); if (bytes != null) { return(iTunesCoverDownloader.CreateBitmap(bytes)); } else { return(BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Big, "icons8-audio-wave-540.png"))); } } }
public async static Task <TagInformation> CreateTagInfoForCD(int drive, int track) { var title = CollectionExtensions.GetValueOrFallback(CDInfoProvider.CdData, $"TITLE{track + 1}", "Unknown song"); var artist = CollectionExtensions.GetValueOrFallback(CDInfoProvider.CdData, $"PERFORMER{track + 1}", "Unknown artist"); var album = CollectionExtensions.GetValueOrFallback(CDInfoProvider.CdData, $"PERFORMER{0}", "Unknown"); album += " - " + CollectionExtensions.GetValueOrFallback(CDInfoProvider.CdData, $"TITLE{0}", ""); var ret = new TagInformation { FileName = $"CD track {track + 1}, on Drive: {drive}", Title = title, Artist = artist, Year = "unknown", Album = album }; if (title != "Unknown song") { var bytes = await iTunesCoverDownloader.GetCoverFor($"{artist} - {title}"); if (bytes != null) { ret.Cover = iTunesCoverDownloader.CreateBitmap(bytes); } } else { ret.Cover = new BitmapImage(ResourceLocator.GetIcon(IconCategories.Big, "icons8-cd-540.png")); } return(ret); }
private async Task UpdateTags(TagInformation tags) { _currentTags = tags; var bytes = await iTunesCoverDownloader.GetCoverFor($"{tags.Title}"); if (bytes != null) { _currentTags.Cover = iTunesCoverDownloader.CreateBitmap(bytes); } else { _currentTags.Cover = new BitmapImage(ResourceLocator.GetIcon(IconCategories.Big, "icons8-radio-540.png")); } NotifyChanged(nameof(CurrentTags)); }
private void BuildTree() { Tree.Clear(); Tree.Add(new NavigationItem { Name = "Albums", Icon = BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Small, "icons8-music-record-48.png")), SubItems = new ObservableCollection <string>(_db.MediaLibary.GetAlbums()) }); Tree.Add(new NavigationItem { Name = "Artists", Icon = BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Small, "icons8-dj-48.png")), SubItems = new ObservableCollection <string>(_db.MediaLibary.GetArtists()) }); Tree.Add(new NavigationItem { Name = "Years", Icon = BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Small, "icons8-calendar-7-48.png")), SubItems = new ObservableCollection <string>(_db.MediaLibary.GetYears().Cast <string>()) }); Tree.Add(new NavigationItem { Name = "Genres", Icon = BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Small, "icons8-musical-notes-48.png")), SubItems = new ObservableCollection <string>(_db.MediaLibary.GetGeneires()) }); Tree.Add(new NavigationItem { Name = "Queries", Icon = BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Small, "icons8-questionnaire-48.png")), SubItems = new ObservableCollection <string>(_db.MediaLibary.GetQueryNames()) }); Tree.Add(new NavigationItem { Name = "Radio", Icon = BitmapHelper.FrozenBitmap(ResourceLocator.GetIcon(IconCategories.Small, "icons8-radio-station-48.png")) }); }