Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom tag in tagLib sharp

I want to add text to a custom tag, to an MP3-file. I tried doing like this, but I can't get the tag to change.

This is my code for now:

TagLib.File f = TagLib.File.Create(@"C:\Users\spunit\Desktop\denna.mp3");
TagLib.Id3v2.Tag t = (TagLib.Id3v2.Tag)f.GetTag(TagTypes.Id3v2);
PrivateFrame p = PrivateFrame.Get(t, "albumtype", true);
p.PrivateData = System.Text.Encoding.Unicode.GetBytes("TAG CHANGED");
f.Tag.Album = "test";
f.Save();

I get the album tag to change, but not the albumtype tag. Am I missing something?

like image 959
spunit Avatar asked Oct 14 '17 12:10

spunit


1 Answers

Unfortunately Id3v2 has a set specification which does not allow custom tags, as defined here.

The code you've referenced from another question does work, you just need to include the reader method to return the private frame data.

See also this question on the Unix Stack Exchange where someone encountered the same problem - an alternative solution could be to use the UserDefinedText tag.

like image 159
Chawin Avatar answered Sep 17 '22 20:09

Chawin