使用 Tag Lib C# 在 Mp3 中嵌入专辑封面



尝试使用 c# 标记库添加专辑封面,

  TagLib.File trackFile = TagLib.File.Create(strLocalFile);
  Picture picture = new Picture("Picture path");
  picture.Type = PictureType.FrontCover;
  picture.MimeType = "image/jpeg";
  picture.Description = "Front Cover";        
  trackFile.Tag.Pictures = new IPicture[1] { picture };
  trackFile.Save();

我在Windows Media Player,iTunes和iPhone中获取图片(仅在纵向模式下)。当我切换到横向模式时,会显示专辑封面,但是当滑过封面流时,专辑封面消失了。

我在代码中缺少某些内容吗?

我在iPhone 4s上使用iTunes 11,iOS 6

让我引用我自己的话:

我发现iTunes讨厌UTF-16,这就是那里的问题所在。

targetMp3File = TagLib.File.Create(...);
// define picture
TagLib.Id3v2.AttachedPictureFrame pic = new TagLib.Id3v2.AttachedPictureFrame();
pic.TextEncoding = TagLib.StringType.Latin1;
pic.MimeType     = System.Net.Mime.MediaTypeNames.Image.Jpeg;
pic.Type         = TagLib.PictureType.FrontCover;
pic.Data         = TagLib.ByteVector.FromPath(...);
// save picture to file
targetMp3File.Tag.Pictures = new TagLib.IPicture[1] { pic };    
targetMp3File.Save();

所以基本上整个事情都在pic.TextEncoding行中。此外,我通过 .NET 常量分配了 Mime 类型。

来源:在 .Net 中使用 Taglib-sharp 2.0.4.0 编写艺术品时遇到问题

这应该适用于iTunes和iPod/iPad/iPhone。但这仅适用于 MP3 文件...

最新更新