当前位置: 首页 > 编程语言 > C#

设置位图为MP3的封面分享

时间:2023-04-11 11:48:42 C#

设置位图为MP3的封面我一直在尝试将位图设置为MP3的封面,但是我做不到似乎让它工作。它没有抛出任何错误,但是当我播放MP3时,位图没有显示。这就是我目前所拥有的:TagLib.Filef=TagLib.File.Create("song.mp3");图片currentImage=getAlbumArt(result.passedAlbumID);图片pic=newPicture();pic.Type=PictureType.FrontCover;pic.MimeType=System.Net.Mime.MediaTypeNames.Image.Jpeg;pic.Description="封面";MemoryStreamms=newMemoryStream();currentImage.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);ms.Position=0;pic.Data=ByteVector.FromStream(ms);f.Tag.Pictures=newIPicture[1]{pic};pictureBox1.Image=currentImage;//测试图像是否正确f.Save();关闭();我正在使用以下代码,都适合我:TagLib.Filefile=TagLib.File.Create(/*pathtoyourmp3file*/);TagLib.Picturepic=newTagLib.Picture();pic.Type=TagLib.PictureType.FrontCover;pic.Description="封面";pic.MimeType=System.Net.Mime.MediaTypeNames.Image.Jpeg;MemoryStreamms=newMemoryStream();/*你的图像*/.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);ms.Position=0;pic.Data=TagLib.ByteVector.FromStream(ms);file.Tag.Pictures=newTagLib.IPicture[]{pic};文件.保存();关闭();根据您提供的代码,我唯一注意到的是我的代码使用了以下代码file.Tag.Pictures=newTagLib.IPicture[]{pic};而不是f.Tag.Pictures=newTagLib.IPicture[1]{pic};所以如果是方括号就试试删除上面的1是C#学习教程:设置位图为MP3封面分享所有内容。如果对大家有用,需要进一步了解C#学习教程,希望大家多多关注。本文来自网络合集,不代表任何内容,如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:

最新推荐
猜你喜欢