1

I am trying to access music metadata. I am able to get all other meta data except album art. How can I get album art?

IReadOnlyList<StorageFolder> MusicFolders = 
    await KnownFolders.MusicLibrary.GetFoldersAsync(CommonFolderQuery.GroupByAlbum);

foreach (var file in MusicFolderList)
{
    StorageFolder mFolder = (StorageFolder)file;
    MusicAlbums obj = new MusicAlbums();
    obj.album = mFolder.Name;

    ThumbnailMode thumbnailMode = ThumbnailMode.MusicView;
    uint size = 100;
    StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(thumbnailMode, size);
    BitmapImage AlbumThumb = new BitmapImage();
    AlbumThumb.SetSource(thumbnail);
    obj.folderArt = AlbumThumb;

    MusicProperties musicProperties = 
        await mFolder.Properties.GetMusicPropertiesAsync();
    obj.artist = musicProperties.Artist;                       

    MusicCollection.Add(obj);
}

public class MusicAlbums
{
    public BitmapImage folderArt { get; set; }
    public string album { get; set; }
    public string artist { get; set; }
}
Mikko Viitala
  • 8,344
  • 4
  • 37
  • 62
Sajeev C
  • 1,538
  • 4
  • 17
  • 30

1 Answers1

3

As for now it seems that getting thumbnail of audio file is unsupported - this method will return default icon instead of expected one - reference MSDN:

In Windows Phone Store apps, the StorageFile.GetThumbnailAsync method returns the default icon for a music file instead of the expected icon. This happens when you call the StorageFile.GetThumbnailAsync method with a ThumbnailMode value of MusicView.

Contrary getting thumbnail of an image works just fine.

You may try to use TagLib.

Romasz
  • 29,662
  • 13
  • 79
  • 154
  • Can you include a sample to show how to fetch album art in this context using Tag lib. @Romasz – Sajeev C Nov 28 '14 at 10:44
  • 1
    @WD The are already few examples (I haven't tried them): [one](http://stackoverflow.com/a/25627653/2681948), [two](http://stackoverflow.com/q/13404957/2681948), [three](http://stackoverflow.com/a/17905163/2681948) and probably more. – Romasz Nov 28 '14 at 11:02