我编写了一个函数,该函数应该从 MPEG 文件中删除所有标签,APIC 标签除外,但我得到了混合和不可预测的结果。有时,除了“年份”之外的所有标签都被正确删除(大多数情况下都会发生这种情况),有时,除了“年份”标签之外,还有一个或多个其他标签。
我肯定做错了什么。这是我的功能:
void stripTags(const char* path) {
MPEG::File m(path);
m.strip(MPEG::File::ID3v1 | MPEG::File::APE, true); //I added this because otherwise, all tags would stay the first time I executed stripTags(). The second time I would execute it then the tags would be mostly gone (except for "year" as mentioned)
ByteVector handle = "APIC";
ID3v2::Tag *t = m.ID3v2Tag();
if (t) {
for (ID3v2::FrameList::ConstIterator it = t->frameList().begin(); it != t->frameList().end(); it++) {
if ((*it)->frameID() != handle) {
t->removeFrames((*it)->frameID());
it = t->frameList().begin(); //since the doc says that removeFrames invalidates the pointer returned by frameList, I update this pointer after each removal
}
}
m.save();
}
m.strip(MPEG::File::ID3v1 | MPEG::File::APE, true);
}
谢谢您的帮助