问题
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