Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ id3lib:复制帧不起作用_C++_Id3lib - Fatal编程技术网

C++ id3lib:复制帧不起作用

C++ id3lib:复制帧不起作用,c++,id3lib,C++,Id3lib,我正在尝试将所有ID3v2标记从一个文件复制到另一个文件。但是我的代码不起作用(标签保持不变),我不知道为什么 ID3_Tag sFile, tFile; sFile.Link("source.mp3", ID3TT_ID3V2); tFile.Link("target.mp3"); tFile.Strip(); ID3_Tag::Iterator* sFrItr = sFile.CreateIterator(); ID3_Frame* sFrame = NULL; while (NULL

我正在尝试将所有ID3v2标记从一个文件复制到另一个文件。但是我的代码不起作用(标签保持不变),我不知道为什么

ID3_Tag sFile, tFile;

sFile.Link("source.mp3", ID3TT_ID3V2);
tFile.Link("target.mp3");

tFile.Strip();

ID3_Tag::Iterator* sFrItr = sFile.CreateIterator();
ID3_Frame* sFrame = NULL;
while (NULL != (sFrame = sFrItr->GetNext()))
{
    tFile.AddFrame(sFrame);
}
delete sFrItr;

tFile.Update();

此代码主要基于。我之前与id3没有任何关系,所以我可能只是不了解帧和字段是如何工作的。

问题是,当触发
Update()
时,添加到
tFile
id3\u帧不再存在。正确的方法是创建指向
ID3\u帧
s副本的指针,并将它们附加到
ID3\u标记

while (NULL != (sFrame = sFrItr->GetNext()))
{
    tFile.AttachFrame(new ID3_Frame(*sFrame));
}
AttachFrame()
负责内存并在之后删除数据本身