Only the first ID3v2 frame can be accessed

Scott Wheeler wheeler at kde.org
Sun Jan 6 07:53:45 CET 2008


Gabriel Burca wrote:
> I tried using taglib version 1.4 to read all the frames in an MP3 ID3v2 tag, but
> was only able to obtain the first frame. Searching for some sample code on-line
> I found tagdump2.cpp which also seems to only display the first frame. Is this a
> known issue, or is there an error in my (and the tagdump2 author's) usage of the
> library?
>
> The tagdump2 file can be found at:
> http://prokyon3.cvs.sourceforge.net/prokyon3/prokyon3/tools/tagdump2.cpp?revision=1.3&view=markup
>
> My code does essentially the same thing:
>
> TagLib::MPEG::File mp(filePath);
> TagLib::ID3v2::FrameList allFrames = mp.ID3v2Tag()->frameList();
> cout << "Frames found: " << allFrames.size()); // Always reports just 1 frame
> std::list<TagLib::ID3v2::Frame *>::iterator iter = allFrames.begin();
> while (iter != allFrames.end()) {
>     // Show frame contents
>     iter++;
> }
>
> If I remove the first frame from the mp3 file, the code will show me the next
> one, but always just one frame. The frameList() call seems to only return a
> 1-element list.
>   

The example works fine here -- on the file I just tried it on it reports
7 frames.  My guess would be that either:

- You're testing this on a file that is corrupt in some way
- You're removing things from the list while iterating over it, which
makes the iterator invalid

-Scott



More information about the taglib-devel mailing list