Constructing an ID3v2::Frame without a file [SOLVED]
Fred Gleason
fredg at paravelsystems.com
Fri Aug 9 21:33:36 BST 2019
On Fri, 2019-08-09 at 19:37 +0200, Scott Wheeler wrote:
> Not quite. You have to parse the header to know how big the tag is,
> so if you want to do that you have to subclass ID3v2::Tag, handle
> parsing the header yourself (by calling ID3v2::Header::setData(...)),
> and then call ID3v2::Tag::parse(...) (protected).
This turned out to be quite simple.
id3tag.h:
*** snip snip ***
#ifndef ID3TAG_H
#define ID3TAG_H
#include <QByteArray>
#include <id3v2tag.h>
class Id3Tag : public TagLib::ID3v2::Tag
{
public:
Id3Tag(const QByteArray &data);
};
#endif // ID3TAG_H
*** snip snip ***
id3tag.cpp:
*** snip snip ***
#include <tbytevector.h>
#include "id3tag.h"
Id3Tag::Id3Tag(const QByteArray &data)
: TagLib::ID3v2::Tag()
{
TagLib::ByteVector bytes(data.constData(),data.size());
header()->setData(bytes.mid(0,10));
parse(bytes.mid(10));
}
*** snip snip ***
Where 'data' contains the raw bytes of a complete ID3v2 tag [including
header(s) and footer].
THANK YOU to everyone who participated in this thread!
Cheers!
|---------------------------------------------------------------------|
| Frederick F. Gleason, Jr. | Chief Developer |
| | Paravel Systems |
|---------------------------------------------------------------------|
| There cannot be a crisis next week. My schedule is already full. |
| |
| -- Henry Kissinger |
|---------------------------------------------------------------------|
More information about the taglib-devel
mailing list