Created
September 16, 2013 13:54
-
-
Save scotchi/6580980 to your computer and use it in GitHub Desktop.
Example from TagLib mailing list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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