mp3 - Remove all tags except APIC with TagLib in C++ -


i wrote function supposed remove tags mpeg file, except apic tag(s), i'm getting mixed , unpredictable results. sometimes, tags except "year" correctly removed (this happens of time), sometimes, 1 or more other tags stay additionally "year" tag.

i'm doing wrong. here function:

void striptags(const char* path) {     mpeg::file m(path);     m.strip(mpeg::file::id3v1 | mpeg::file::ape, true); //i added because otherwise, tags stay first time executed striptags(). second time execute tags gone (except "year" mentioned)     bytevector handle = "apic";     id3v2::tag *t = m.id3v2tag();     if (t) {         (id3v2::framelist::constiterator = t->framelist().begin(); != t->framelist().end(); it++) {             if ((*it)->frameid() != handle) {                 t->removeframes((*it)->frameid());                 = t->framelist().begin(); //since doc says removeframes invalidates pointer returned framelist, update pointer after each removal             }         }         m.save();     }     m.strip(mpeg::file::id3v1 | mpeg::file::ape, true); } 

thanks help

in loop, when have removed tag, reset iterator. loop continues , first thing it++, meaning loop skip 1 entry.

you modify loop e.g.

for (id3v2::framelist::constiterator = t->framelist().begin(); != t->framelist().end(); /* nothing here */) {     if ((*it)->frameid() != handle) {         t->removeframes((*it)->frameid());         = t->framelist().begin();     } else {         ++it;     } } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -