0

Is it possible to set the COMPILATION tag in iTunes using taglib-sharp?

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?

There are a lot of questions answered here on how to do this using Id3v2 tags, however not for iTunes tags. I also could not find any helpful documentation.

Any help very much appreciated!

kf198
  • 35
  • 1
  • 5

2 Answers2

0

Based on the official specifications of ID3, you seem to be searching for the TCMP (iTunes Compilation Flag) Text Frame. Set it to the appropriate value and iTunes will do the rest obviously. The TCMP Text Frame takes a boolean value.

This is a simple text frame that iTunes uses to indicate if the file is part of a compilation.

 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();
Fᴀʀʜᴀɴ Aɴᴀᴍ
  • 6,131
  • 5
  • 31
  • 52
0

To make Farhan's answer work in TagLibSharp v2.3.0 I had to implement it something like this:

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();