Skip to content

Instantly share code, notes, and snippets.

@scotchi
Created September 16, 2013 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scotchi/6580980 to your computer and use it in GitHub Desktop.
Save scotchi/6580980 to your computer and use it in GitHub Desktop.
Example from TagLib mailing list
#include <iostream>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <privateframe.h>
static void AddTag(const char * payload, const char * URL)
{
TagLib::MPEG::File f(URL);
TagLib::ID3v2::Tag *tag = f.ID3v2Tag();
TagLib::ID3v2::PrivateFrame *frame = new TagLib::ID3v2::PrivateFrame ();
TagLib::ByteVector v = TagLib::ByteVector::fromCString(payload, strlen(payload));
frame->setOwner("xxxxxxxxxxxx");
frame->setData(v);
tag->addFrame(frame);
f.save();
}
static void CheckFrameSize(const char * URL)
{
TagLib::MPEG::File f(URL);
TagLib::ID3v2::Tag *tag = f.ID3v2Tag();
TagLib::ID3v2::FrameList frames = tag->frameList("PRIV");
for(TagLib::ID3v2::FrameList::ConstIterator it = frames.begin();
it != frames.end(); ++it)
{
std::cout << "PRIV Frame Size: " << (*it)->size() << std::endl;
}
}
int main(int argc, const char *argv[])
{
for(int i = 1; i < argc; i++)
{
const char *file = argv[i];
std::cout << "=== " << file << " ===" << std::endl;
AddTag("foobar", file);
CheckFrameSize(file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment