我正在尝试访问音乐元数据。我能够获得除专辑封面之外的所有其他元数据。我怎样才能获得专辑封面?
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; }
}
答案 0 :(得分:3)
至于现在似乎不支持获取音频文件的缩略图 - 此方法将返回默认图标而不是预期的图标 - reference MSDN:
在Windows Phone应用商店中,StorageFile.GetThumbnailAsync方法返回音乐文件的默认图标,而不是预期的图标。当您使用ThumbViewMode值MusicView调用StorageFile.GetThumbnailAsync方法时会发生这种情况。
相反,获取图像的缩略图效果很好。
您可以尝试使用TagLib。