日期:2014-05-17  浏览次数:20916 次

关于C# MP3 专辑图片问题
有的mp3文件中存在有专辑图片,但是有的又没有,这个怎么判断一下

------解决方案--------------------
windows有相关api。

自己做可以去读mp3格式说明。
------解决方案--------------------
这个例子里面好像有你要的功能.
http://www.codeproject.com/Articles/55665/MP3-Player-for-Windows-7

核心的代码段:
        private void SetAlbumArt()
        {

            if (playlist.SelectedItem != null)
            {
                TagLib.File file = TagLib.File.Create(playlist.SelectedItem.ToString());
                if (file.Tag.Pictures.Length > 0)
                {
                    var bin = (byte[])(file.Tag.Pictures[0].Data.Data);
                    albumart.Image = 
Image.FromStream(new MemoryStream(bin)).GetThumbnailImage
(100, 100, null, IntPtr.Zero);

                }
                else
                {
                    albumart.Image = Properties.Resources.gramophone;
                }
            }            
        }