mono / taglib-sharp

Library for reading and writing metadata in media files
GNU Lesser General Public License v2.1
1.29k stars 312 forks source link

Can't read/write custom Tags to .wav file #258

Open forReason opened 3 years ago

forReason commented 3 years ago

So for normal tags such as title, artist etc, the library works fine.

I am in dare need for custom fields. I have looked at the readme example which states the following code:

var tfile = TagLib.File.Create(@"C:\My song.flac");
var custom = (TagLib.Ogg.XiphComment) tfile.GetTag(TagLib.TagTypes.Xiph);

// Read
string [] myfields = custom.GetField("MY_TAG");
Console.WriteLine("First MY_TAG entry: {0}", myfields[0]);

// Write
custom.SetField("MY_TAG", new string[] { "value1", "value2" });
custom.RemoveField("OTHER_FIELD");
rgFile.Save();

unfortunately, this does not bring me any further. When I execute the code, after the following section, the variable custom is null. There is no error thrown:

var tfile = TagLib.File.Create(@"C:\My song.wav");
var custom = (TagLib.Ogg.XiphComment) tfile.GetTag(TagLib.TagTypes.Xiph);

However. Later, when trying to add or remove a tag, a NullReferenceException is thrown, stating that custom == null:

custom.SetField("Geolocation", new string[] { this.Latitude.ToString(), this.Longitude.ToString() }) ;
vrdriver commented 1 year ago

Hi @forReason . I'd asked this question a few years ago. Still no solution as yet. https://github.com/mono/taglib-sharp/issues/234