[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: Constructing an ID3v2::Frame without a file [SOLVED]
From:       Fred Gleason <fredg () paravelsystems ! com>
Date:       2019-08-09 20:33:36
Message-ID: aa0f90e661a1c57bd0ef29ee177944a384356eb9.camel () paravelsystems ! com
[Download RAW message or body]

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   |
|---------------------------------------------------------------------|

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic