[英]c# how to get the cover art of a mp3 file into a picturebox windows forms
我正在尝试使用Windows窗体中的WMPlib制作mp3应用程序。 现在,我想将mp3文件的封面放入图片框。 我通过Internet进行了一些研究,但是它使用的是不同的库,因此我无法弄清楚如何使用它们或将其实现为Windows窗体。
我尝试了几件事
private void getImageFromSong()
{
System.Drawing.Image currentImage = null;
// In method onclick of the listbox showing all mp3's
TagLib.File f = new TagLib.Mpeg.AudioFile(file);
if (f.Tag.Pictures.Length > 0)
{
TagLib.IPicture pic = f.Tag.Pictures[0];
MemoryStream ms = new MemoryStream(pic.Data.Data);
if (ms != null && ms.Length > 4096)
{
currentImage = System.Drawing.Image.FromStream(ms);
// Load thumbnail into PictureBox
AlbumArt.Image = currentImage.GetThumbnailImage(100, 100, null, System.IntPtr.Zero);
}
ms.Close();
}
}
和
pbSongImage.ImageLocation = paths[lbSongs.SelectedIndex];
我真的不知道该怎么做,或者如何使用Taglib。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.