5

I'm trying to save new artist and title id3 tags into tracks. Loading tags from tracks working good, also editing title for track is working fine. But when i try to edit performer (artist) it didn't change anything. Here is the code

public void renameID3(string artist,string title)
{ 
   using (TagLib.File f = TagLib.File.Create(FInfo.FullName))
        {
            f.Tag.Artists[0] = artist; //Both of them are not ...
            f.Tag.Performers[0] = artist; //working


            f.Tag.Title = title; //This works fine
            f.Save();
        }
  }

Plus I looked the definiton of FirstPerformer and FirstPerformer members of TagLib class but they don't have any set method. Anyone know how to solve this?

Ali Yeşilkanat
  • 597
  • 1
  • 7
  • 21

3 Answers3

9

Stuck with the very same problem. Found that clearing Performers first makes it work as intended:

using(TagLib.File tlFile = TagLib.File.Create(newFileName)){
    //tlFile.Tag.Performers = new []{translateDict[author]}; //doesn't work
    tlFile.Tag.Performers = null; //clearing out performers
    tlFile.Tag.Performers = new []{translateDict[author]}; //works now
    tlFile.Save();
}
  • You shouldn't need the `=null` step. The problem is that Performers, et al return *new* array so editing it doesn't make changes to the underlying data structure. It should really return an IEnumerable but I was young and reckless. – Brian Nickel Jul 03 '13 at 06:06
  • @BrianNickel Can you please take alook at question: http://stackoverflow.com/questions/35414734/cant-add-image-keywords-if-there-were-no-keywords-to-begin-with-taglib-sharp/35421960#35421960 – Sinnich Feb 29 '16 at 08:36
1
TagLib.File f = TagLib.File.Create(yourFile);
f.Tag.AlbumArtists = new string[] { "Artist 1", "Artist 2", ... };
Nerdroid
  • 13,398
  • 5
  • 58
  • 69
Sledge
  • 11
  • 1
0

This worked for me:

TagLib.File file = TagLib.File.Create (fname);
file.Tag.Performers = new String[1] { artist };
file.Save();
razz
  • 9,770
  • 7
  • 50
  • 68