7

How can i get the AlbumArt image in the mp3 file? I am developing Windows Store app with c#.

MusicProperties class gives me Album name artist name vs. But it cant give me albumart.

4

3 回答 3

7

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

文件和文件夹缩略图示例

如果您想保存专辑封面,请查看如何在 Windows 8 Metro 应用程序中将保存的缩略图图像存储在设备中 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;
    }
}
于 2013-09-17T08:02:48.743 回答
3

这是我针对第三个 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));
于 2014-09-02T16:00:13.710 回答
1

我在这里找到了一个解决方案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
     }
}
于 2013-12-29T13:26:53.430 回答