简体   繁体   English

如何使用 taglib-sharp 在 iTunes 中设置“编译”标签?

[英]How to set the 'COMPILATION' tag in iTunes using taglib-sharp?

Is it possible to set the COMPILATION tag in iTunes using taglib-sharp?是否可以使用 taglib-sharp 在 iTunes 中设置编译标签?

Unfortunately, there seems to be nothing similar to this:不幸的是,似乎没有类似的东西:

TagLib.File tagFile = TagLib.File.Create(file);  //.m4a file
tagFile.Tag.IsComilation = true;
tagFile.Save();

If not natively supported, is it possible to add an custom tag?如果本机不支持,是否可以添加自定义标签? Possibly through the use of TagLib.Mpeg4.AppleTag or TagLib.Mpeg4.AppleAdditionalInfoBox ?可能通过使用TagLib.Mpeg4.AppleTagTagLib.Mpeg4.AppleAdditionalInfoBox

There are a lot of questions answered here on how to do this using Id3v2 tags, however not for iTunes tags.这里有很多关于如何使用 Id3v2 标签的问题得到解答,但不适用于 iTunes 标签。 I also could not find any helpful documentation.我也找不到任何有用的文档。

Any help very much appreciated!非常感谢任何帮助!

Based on the official specifications of ID3, you seem to be searching for the TCMP (iTunes Compilation Flag) Text Frame . 根据ID3的官方规范 ,您似乎正在搜索TCMP (iTunes Compilation Flag) Text Frame Set it to the appropriate value and iTunes will do the rest obviously. 将其设置为适当的值,iTunes显然会完成其余工作。 The TCMP Text Frame takes a boolean value. TCMP Text Frame采用布尔值。

This is a simple text frame that iTunes uses to indicate if the file is part of a compilation. 这是iTunes使用的简单文本框,用于指示文件是否为编辑的一部分。

  1 if part of a compilation 0 or not present if not part of a compilation 

So you can set it like this: 因此,您可以这样设置:

TagLib.File tagFile = TagLib.File.Create(file);
Id3v2.Tag tag = (Id3v2.Tag)tagFile.GetTag(TagTypes.Id3v2, true);
tag.SetTextFrame(FrameType.TCMP, "1"); // Change value accordingly...
tagFile.Save();

To make Farhan's answer work in TagLibSharp v2.3.0 I had to implement it something like this:为了使 Farhan 的答案在 TagLibSharp v2.3.0 中起作用,我必须像这样实现它:

var mp3File = TagLib.File.Create(destTrackFile);                        
TagLib.Id3v2.Tag tag = (TagLib.Id3v2.Tag)mp3File.GetTag(TagLib.TagTypes.Id3v2, true);
TagLib.ReadOnlyByteVector TCMP = "TCMP";
tag.SetTextFrame(TCMP, "1");
mp3File.Save();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM