标签库:如何编辑专辑艺术家? [英] taglib : how to edit Album Artist?
问题描述
如何修改MP3文件的专辑艺术家字段与库标签库?
是否有类似的东西:
How to modify the "Album Artist" field of a MP3 file with the library TagLib ? Is there something similar to :
f.tag()->setArtist("blabla");
推荐答案
ID3v2的实际上并不支持所谓的专辑艺术家字段中。的iTunes使用TPE2帧,这被认为是:
ID3v2 doesn't actually support a field called "album artist". iTunes uses the TPE2 frame, which is supposed to be:
在'乐队/乐团/伴奏'帧用于有关在录制表演的更多信息。
TPE2
The 'Band/Orchestra/Accompaniment' frame is used for additional information about the performers in the recording.
有关帧的完整列表,请参阅 http://id3.org/id3v2.3.0#Declared_ID3v2_frames一>
For a complete list of frames see http://id3.org/id3v2.3.0#Declared_ID3v2_frames.
要编写与标签库,这会做的伎俩:
To write that with TagLib, this would do the trick:
#include <mpegfile.h>
#include <id3v2tag.h>
#include <textidentificationframe.h>
int main()
{
TagLib::MPEG::File file("foo.mp3");
TagLib::ByteVector handle = "TPE2";
TagLib::String value = "bar";
TagLib::ID3v2::Tag *tag = file.ID3v2Tag(true);
if(!tag->frameList(handle).isEmpty())
{
tag->frameList(handle).front()->setText(value);
}
else
{
TagLib::ID3v2::TextIdentificationFrame *frame =
new TagLib::ID3v2::TextIdentificationFrame(handle, TagLib::String::UTF8);
tag->addFrame(frame);
frame->setText(value);
}
file.save();
return 0;
}
如果你只是想删除的图像,你可以简单地做:
If you just want to remove the frames, you can simply do:
TagLib::MPEG::File file("foo.mp3");
TagLib::ID3v2::Tag *tag = file.ID3v2Tag();
if(tag)
{
tag->removeFrames("TPE2");
file.save();
}
这篇关于标签库:如何编辑专辑艺术家?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!