I've been using taglib-sharp for many years on our Upload script for our website.
Today, I found out how to access the Duration from it, so now I am using taglib-sharp for all my tags.
(For those interested in the Duration)
Code:
Dim strDuration = mp31.Properties.Duration
Dim strDurations As String = strDuration.ToString("mm\:ss")
The MP3 Editor I use MP3Tag
Allows you to create Custom Tags.
An example of a tag is.
Producer Eddie Kramer
What I need is to have taglib-sharp read these Custom Tags.
From what I have read, it seems that it is possible.
I found this here on SO. adding custom tag using the taglib-sharp library
And this is what I tried. (After converting it over from C# to VB)
Code:
Imports TagLib.Id3v2
Dim f As File = File.Create(Server.MapPath("/Files/Do_You_Love_Me.mp3"))
Dim t As TagLib.Id3v2.Tag = CType(f.GetTag(TagTypes.Id3v2), TagLib.Id3v2.Tag)
Dim p As PrivateFrame = PrivateFrame.[Get](t, "PRODUCER", False)
Dim strProducer As String = Encoding.Unicode.GetString(p.PrivateData.Data)
Also tried this as well, but with the same error as shown below.
Code:
Dim tfile = f
Dim custom = CType(tfile.GetTag(TagLib.TagTypes.Xiph), TagLib.Ogg.XiphComment)
Dim myfields As String() = custom.GetField("PRODUCER")
When I run it, I get this error.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
p was Nothing.
So, it is not reading the custom tag.
It seems it is not being initialized, but how?
I installed VS Code and then installed the Hex Editor from Microsoft.
I loaded the MP3 file into Code and invoked the Hext Editor. The tag "PRODUCER" and its value are clearly visible.
So, the tag is present but is just not being read through the TagLib-sharp code.
Viewing the code from the ID3v2Library.pas (Delphi Component File)
Code:
ConvertString2FrameID('TXXX', Frames[FrameIndex].ID);
I see where the FRAME ID matches what I am seeing in the HEX Editor for the MP3 file.
All the CUSTOM TAGS are listed with the FRAMEID of **TXXX**.
So, the code is erroring out on these lines for both codes.
Code:
Dim p As PrivateFrame = PrivateFrame.[Get](t, "PRODUCER", False) ' This one
Dim myfields As String() = custom.GetField("PRODUCER") ' And then this one.
What needs to be initialized to make this work is to read the custom metadata tags from the mp3 files.
Thanks.
Wayne