Get Albumart in .mp3 file for Windows Store App

有些话、适合烂在心里 提交于 2019-12-22 05:43:08

问题


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.


回答1:


Check out MSDN sample to show thumbnail of any file. It also consists how to retrieve the album art.

File and folder thumbnail sample

If you want to save the album art check out How to store save Thumbnail image in device in windows 8 metro apps c#

UPDATE 1

MediaFile is StorageFile. ImageControl is <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;
    }
}



回答2:


here's my quick and short solution for that problem thirding 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));



回答3:


I found a solution here 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
     }
}


来源:https://stackoverflow.com/questions/18807320/get-albumart-in-mp3-file-for-windows-store-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!