Search code examples
c#.netid3taglib-sharp

Is there an equivalent field to Label/Publisher in taglib-sharp?


I'm trying to update the label/publisher field using Taglib-sharp, but I can't see it anywhere in its Object Hierarchy using Object Browser.

I've searched through google and the documentation and it looks like it's a field that's not catered for.

Before I look for alternatives (can any one suggest any?) that can edit those field, I thought I'd have one last crack and ask within the StackOverflow community who is familiar with TagLib-sharp that had a more informed opinion?

Thanks in Advance,

Francis

Update : I've investigated other libraries such as mpg123 & UltraID3Lib but they seem to have the same limitations.


Solution

  • Well, Daniel Fuchs answer didn't work for me. But, it was a beginning.

    The step by step to add a field in the TagLib-sharp code is:

    1. Download Source

    2. Open the File TagLib/Tag.cs and insert the following code (I inserted it below PerformersSort, line 250):

      public virtual string Publisher
      {
          get { return ""; }
          set { }
      }
      
    3. Open the File TagLib/Id3v2/Tag.cs and insert the following code (I inserted it below PerformersSort, line 1292):

      public override string Publisher
      {
          get { return GetTextAsString(FrameType.TPUB); }
          set { SetTextFrame(FrameType.TPUB, value); }
      }
      
    4. Open the File TagLib/Id3v2/FrameTypes.cs and insert the following code (I inserted it below TPOS, line 71):

      public static readonly ReadOnlyByteVector TPUB = "TPUB";
      
    5. Now comes the "Aha" thing. Open the File TagLib/CombinedTag.cs and insert the following code (I inserted it below PerformersSort, line 318):

      public override string Publisher
      {
          get
          {
              foreach (Tag tag in tags)
              {
                  if (tag == null)
                      continue;
      
                  string value = tag.Publisher;
      
                  if (value != null)
                      return value;
              }
      
              return null;
          }
      
          set
          {
              foreach (Tag tag in tags)
                  if (tag != null)
                      tag.Publisher = value;
          }
      }
      
    6. Finally, compile the code.

    IMPORTANT: I had problems compiling the code, as well. You must download the SharpZipLib dll (.NET 2.0) and include this dll in the taglib project. Also, I needed to install NUnit, which I made with Nuget. At last, I commented the GDK lib and all its errors inside the test code, since in production it won't be used.