How to write multiple values to one ID3v2.4 frame?

Michael Helmling michaelhelmling at posteo.de
Sat Oct 5 09:19:12 UTC 2013


Hi,

Simply use
frame->setText(values)
which is also declared with a StringList argument.

Regards,
Michael
Am 05.10.2013 04:07, schrieb Duke Yin:
> I'm trying to figure out how to write multiple values to an ID3v2.4
> tag.  ID3v2.4 spec is to have a single frame where all values are
> joined together with a null character.  (By contrast, ID3v2.3 uses a
> backslash instead of null.  XiphComment uses multiple frames instead
> of a single frame with a delimiting character.)  I couldn't find any
> code examples for ID3v2.4, so I tried two approaches which failed.
>
> Approach 1:  add a new frame for each value
> > // for each string {
> > TagLib::ID3v2::TextIdentificationFrame *frame = new
> TagLib::ID3v2::TextIdentificationFrame(keyStr, TagLib::String::UTF8);
> > id3v2->addFrame(frame);
> > frame->setText(str);
> > // } close for loop
> Result 1:  incorrect - multiple frames instead of a single frame.
>
> Approach 2:  manually separate the values with the null character
> > TagLib::StringList values;
> > // { for each string, append the string to "values" }
> > TagLib::ID3v2::TextIdentificationFrame *frame = new
> TagLib::ID3v2::TextIdentificationFrame(keyStr, TagLib::String::UTF8);
> > id3v2->addFrame(frame);
> > frame->setText(values.toString('\0'));
>  
> Result 2: wrong and inconsistent behaviors:
> - All values can be read by foobar2000
> - The last value can't be read by Mp3tag, apparently because the text
> encoding size is double what Mp3tag would write with the same input
> - All values except the first can't be read by TagLib when the file is
> opened again with code similar to
> https://gist.github.com/Horrendus/622816 .
>
> I'm not sure if I'm using the null character correctly in Approach 2
> given how many apps it breaks (although foobar2000 handles it).   I'm
> hoping there's an easy way to write multiple values to ID3v2.4 that I
> missed.  What is the correct way to do this?
>
>
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20131005/dd6bc714/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20131005/dd6bc714/attachment.sig>


More information about the taglib-devel mailing list