Detect whether or not an id3v1 tag exists

Joel Verhagen joel.verhagen at
Fri Dec 10 15:23:43 CET 2010

I have looked more on this topic and even raised the question on
StackOverflow, so my C++ superiors could take a look:

Hexagon points out that at the end of the MPEG::File::read function is
a call to ID3v2Tag(true); and ID3v1Tag(true);

Does anyone know why this is here? In the meantime, I created three
replacement functions bool hasID3v2(), bool hasID3v1(), bool hasAPE()
that pass through the internal boolean used to say whether or not the
MPEG file has ID3v1/ID3v2/APE tags.

Joel Verhagen

On Fri, Dec 3, 2010 at 12:25 PM, Joel Verhagen <joel.verhagen at> wrote:
> Is there a way in TagLib to detect whether or not an ID3v1 tag exists or not in an MPEG file? The isEmpty function checks whether or not any specific tags (album, year, etc.) exist, but not whether the id3v1 block itself is there. See this entry in the TagLib documentation:
> This says it will return a NULL pointer if there is no id3v1 tag found. This doesn't happen. For example, I ran an MP3 through the strip-id3v1 program in the examples. I then ran this same mp3 through my own program that tells me if the pointer id3v1 tag object is NULL. The pointer returned is not NULL. Does TagLib have its own special definition for a NULL pointer? Is this a bug? What could I be doing wrong?
> Here is my code.
> TagLib::MPEG::File file(filePath);
> TagLib::ID3v1::Tag * id3v1 = file.ID3v1Tag();
> if(id3v1 == NULL)
> {
> qDebug() << "null";
> }
> Joel Verhagen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpegfile.cpp
Type: text/x-c++src
Size: 15543 bytes
Desc: not available
Url : 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpegfile.h
Type: text/x-chdr
Size: 10541 bytes
Desc: not available
Url : 

More information about the taglib-devel mailing list