Weird genre problem with taglib

Θεόφιλος Ιντζόγλου int.teo at gmail.com
Sun Jun 25 20:20:07 CEST 2006


I seem to have a problem with files that only have ID3v1 tags when I'm using 
the following code:

        TagLib::MPEG::File *f = dynamic_cast<TagLib::MPEG::File 
*>(fileref->file());

        if ( f ) {
            if ( !f->ID3v2Tag() && f->ID3v1Tag() ) {
                qDebug( "ID3v1 and no ID3v2 detected!" );
                // Copy id3v1 tag to id3v2 tag
                TagLib::ID3v1::Tag *v1tag = f->ID3v1Tag();
                TagLib::ID3v2::Tag *v2tag = f->ID3v2Tag( true );
                v2tag->setGenre( v1tag->genre() );
                qDebug( TStringToQString( v1tag->genre() ) );
                qDebug( TStringToQString( v2tag->genre() ) );
		....

The problem is that although I get the correct genre with v1tag->genre(), when 
I use in the third qDebug the v2tag->genre() method I don't get the genre as 
text but as the corresponding number for it. I had a look at taglib's sources 
and saw that in id3v2tag.cpp in 'String ID3v2::Tag::genre() const' a check is 
done about the header version. Could it be that because the ID3v2 tag was 
just created the major version of the header isn't 4 and so the check fails 
and it then returns the string as it is (a number that is)?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/taglib-devel/attachments/20060625/4f260090/attachment.pgp 


More information about the taglib-devel mailing list