setting and reading multiple genres
Andrew Lake
jamboarder at gmail.com
Mon Nov 8 18:12:20 CET 2010
On Mon, Nov 1, 2010 at 9:24 PM, Andrew Lake wrote:
> I am working on trying to set multiple id3v2 genres and I need a
> little help to get me on the right track. Below is the code snippet
> I'm using (genreList is QStringList containing the genres i'd like to
> set):
>
> if (!genreList.isEmpty()) {
> TagLib::String
> genre(genreList.at(0).toUtf8().data(), TagLib::String::UTF8);
> for (int i = 1; i < genreList.count(); i++) {
> genre.append('\0');
> genre.append(genreList.at(i).toUtf8().data());
> }
> file.tag()->setGenre(genre);
> }
> file.save();
>
> The above snippet only saves the first genre in genreList. Could
> anyone point me to the correct way to save multiple genres?
> Additionally, will this kind of method work for multiple artists?
>
> Thanks for any help anyone can provide.
Never mind, I found out how to do it correctly.
I'm sure everyone else probably knows but in case anyone else had
trouble figuring it out like I did, it turned out to be relatively
easy:
TextIdentificationFrame::setText() takes a TagLib::StringList as an
argument which will set the field values. All that's needed is to
convert QStringList to a TagLib::StringList, get the
TextIdentificationFrame for genre ("TCON") and call setText with the
new TagLib::StringList. Reading it back is just the
TextIdentificationFrame::fieldList().
Thanks again for all your hard work on taglib.
peace,
Andrew Lake
More information about the taglib-devel
mailing list