在Windows Store App的.mp3文件中获取Albumart

时间:2013-09-14 23:15:22

标签: c# windows-8 windows-runtime microsoft-metro windows-store-apps

如何在mp3文件中获取AlbumArt图像?我正在使用c#开发Windows应用商店应用。

MusicProperties课程给了我相册名称艺术家姓名vs.但它不能给我albumart。

3 个答案:

答案 0 :(得分:5)

查看MSDN示例以显示任何文件的缩略图。它还包括如何检索专辑封面。

File and folder thumbnail sample

如果您想保存专辑封面,请查看How to store save Thumbnail image in device in windows 8 metro apps c#

更新1

MediaFileStorageFileImageControl<Image ... />

using (StorageItemThumbnail thumbnail = await MediaFile.GetThumbnailAsync(ThumbnailMode.MusicView, 300))
{
    if (thumbnail != null && thumbnail.Type == ThumbnailType.Image)
    {
        var bitmapImage = new BitmapImage();
        bitmapImage.SetSource(thumbnail);
        ImageControl.Source = bitmapImage;
    }
}

答案 1 :(得分:1)

这是我快速而简短的解决方案来解决TagLib#:(http://taglib.github.io/

using TagLib;
var file = TagLib.File.Create(filename);
var bin = (byte[])(file.Tag.Pictures[0].Data.Data);
imageBox.Image = Image.FromStream(new MemoryStream(bin));

答案 2 :(得分:0)

我在这里找到了一个解决方案How to: Get IDE Tags and Thumbnails of a file

var bitmapImage = new BitmapImage();

//Get Album cover
using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.MusicView, 300))
{
     if (thumbnail != null && thumbnail.Type == ThumbnailType.Image)
     {
         bitmapImage.SetSource(thumbnail);
     }
     else
     {
         //Error Message here
     }
}