⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tag.cpp

📁 更新mp3
💻 CPP
📖 第 1 页 / 共 3 页
字号:
 **/size_t ID3_Tag::Size() const{  return _impl->Size();}/** Turns unsynchronization on or off, dependant on the value of the boolean ** parameter. ** ** If you call this method with 'false' as the parameter, the ** binary tag will not be unsync'ed, regardless of whether the tag should ** be.  This option is useful when the file is only going to be used by ** ID3v2-compliant software.  See the ID3v2 standard document for futher ** details on unsync. ** ** Be default, tags are created without unsync. ** ** \code **   myTag.SetUnsync(false); ** \endcode ** ** \param bSync Whether the tag should be unsynchronized **/bool ID3_Tag::SetUnsync(bool b){  return _impl->SetUnsync(b);}/** Turns extended header rendering on or off, dependant on the value of the ** boolean parameter. ** ** This option is currently ignored as id3lib doesn't yet create extended ** headers.  This option only applies when rendering tags for ID3v2 versions ** that support extended headers. ** ** \code **   myTag.SetExtendedHeader(true); ** \endcode ** ** \param bExt Whether to render an extended header **/bool ID3_Tag::SetExtendedHeader(bool ext){  return _impl->SetExtended(ext);}/** Turns padding on or off, dependant on the value of the boolean ** parameter. ** ** When using ID3v2 tags in association with files, id3lib can optionally ** add padding to the tags to ensure minmal file write times when updating ** the tag in the future. ** ** When the padding option is switched on, id3lib automatically creates ** padding according to the 'ID3v2 Programming Guidelines'.  Specifically, ** enough padding will be added to round out the entire file (song plus ** tag) to an even multiple of 2K.  Padding will only be created when the ** tag is attached to a file and that file is not empty (aside from a ** pre-existing tag). ** ** id3lib's addition to the guidelines for padding, is that if frames are ** removed from a pre-existing tag (or the tag simply shrinks because of ** other reasons), the new tag will continue to stay the same size as the ** old tag (with padding making the difference of course) until such time as ** the padding is greater than 4K.  When this happens, the padding will be ** reduced and the new tag will be smaller than the old. ** ** By default, padding is switched on. ** ** \code **   myTag.SetPadding(false); ** \endcode ** ** \param bPad Whether or not render the tag with padding. **/bool ID3_Tag::SetPadding(bool pad){  return _impl->SetPadding(pad);}bool ID3_Tag::SetExperimental(bool exp){  return _impl->SetExperimental(exp);}bool ID3_Tag::GetUnsync() const{  return _impl->GetUnsync();}bool ID3_Tag::GetExtendedHeader() const{  return _impl->GetExtended();}bool ID3_Tag::GetExperimental() const{  return _impl->GetExperimental();}void ID3_Tag::AddFrame(const ID3_Frame& frame){  _impl->AddFrame(frame);}/** Attaches a frame to the tag; the tag doesn't take responsibility for ** releasing the frame's memory when tag goes out of scope. ** ** Optionally, operator<< can also be used to attach a frame to a tag.  To ** use, simply supply its parameter a pointer to the ID3_Frame object you wish ** to attach. ** ** \code **   ID3_Frame myFrame; **   myTag.AddFrame(&myFrame); ** \endcode ** ** As stated, this method attaches the frames to the tag---the tag does ** not create its own copy of the frame.  Frames created by an application ** must exist until the frame is removed or the tag is finished with it. ** ** \param pFrame A pointer to the frame that is being added to the tag. ** \sa ID3_Frame **/void ID3_Tag::AddFrame(const ID3_Frame* frame){  _impl->AddFrame(frame);}/** Attaches a frame to the tag; the tag takes responsibility for ** releasing the frame's memory when tag goes out of scope. ** ** This method accepts responsibility for the attached frame's memory, and ** will delete the frame and its contents when the tag goes out of scope or is ** deleted.  Therefore, be sure the frame isn't "Attached" to other tags. ** ** \code **   ID3_Frame *frame = new ID3_Frame; **   myTag.AttachFrame(frame); ** \endcode ** ** \param frame A pointer to the frame that is being added to the tag. **/bool ID3_Tag::AttachFrame(ID3_Frame *frame){  return _impl->AttachFrame(frame);}/** Removes a frame from the tag. ** ** If you already own the frame object in question, then you should already ** have a pointer to the frame you want to delete.  If not, or if you wish to ** delete a pre-existing frame (from a tag you have parsed, for example), the ** use one of the Find methods to obtain a frame pointer to pass to this ** method. ** ** \code **   ID3_Frame *someFrame; **   if (someFrame = myTag.Find(ID3FID_TITLE)) **   { **     myTag.RemoveFrame(someFrame); **   } ** \endcode ** ** \sa ID3_Tag#Find ** \param pOldFrame A pointer to the frame that is to be removed from the **                  tag **/ID3_Frame* ID3_Tag::RemoveFrame(const ID3_Frame *frame){  return _impl->RemoveFrame(frame);}bool ID3_Tag::Parse(ID3_Reader& reader){  return id3::v2::parse(*_impl, reader);}size_t ID3_Tag::Parse(const uchar* buffer, size_t bytes){  ID3_MemoryReader mr(buffer, bytes);  ID3_Reader::pos_type beg = mr.getCur();  id3::v2::parse(*_impl, mr);  return mr.getEnd() - beg;}/** Turns a binary tag into a series of ID3_Frame objects attached to the ** tag. ** ** \code **   ID3_Tag myTag; **   uchar header[ID3_TAGHEADERSIZE]; **   uchar *buffer; **   luint tagSize; ** **   // get ID3_TAGHEADERSIZE from a socket or somewhere **   // ... ** **   if ((tagSize = ID3_IsTagHeader(ourSourceBuffer)) > -1) **   { **     // read a further 'tagSize' bytes in **     // from our data source **     // ... ** **     if (buffer = new uchar[tagSize]) **     { **       // now we will call ID3_Tag::Parse() **       // with these values (explained later) **       myTag.Parse(header, buffer); ** **       // do something with the objects, **       // like look for titles, artists, etc. **       // ... ** **       // free the buffer **       delete [] buffer; **     } **   } ** \endcode ** ** \sa ID3_Frame ** @param header The byte header read in from the data source. ** @param buffer The remainder of the tag (not including the data source) **               read in from the data source. **/size_t ID3_Tag::Parse(const uchar header[ID3_TAGHEADERSIZE], const uchar *buffer){  size_t size = ID3_Tag::IsV2Tag(header);  if (0 == size)  {    return 0;  }  BString buf;  buf.reserve(ID3_TagHeader::SIZE + size);  buf.append(reinterpret_cast<const BString::value_type *>(header),             ID3_TagHeader::SIZE);  buf.append(reinterpret_cast<const BString::value_type *>(buffer), size);  return this->Parse(buf.data(), buf.size());}/** Renders the tag and writes it to the attached file; the type of tag ** rendered can be specified as a parameter.  The default is to update only ** the ID3v2 tag.  See the ID3_TagType enumeration for the constants that ** can be used. ** ** Make sure the rendering parameters are set before calling the method. ** See the Link documentation for an example of this method in use. ** ** \sa ID3_TagType ** \sa Link ** \param tt The type of tag to update. **//** Renders a binary image of the tag into the supplied buffer. ** ** See Size() for an example.  This method returns the actual number of the ** bytes of the buffer used to store the tag.  This will be no more than the ** size of the buffer itself, because Size() over estimates the required ** buffer size when padding is enabled. ** ** Before calling this method, it is advisable to call HasChanged() first as ** this will let you know whether you should bother rendering the tag. ** ** @see    ID3_IsTagHeader ** @see    ID3_Tag#HasChanged ** @return The actual number of the bytes of the buffer used to store the **         tag ** @param  buffer The buffer that will contain the rendered tag. **/size_t ID3_Tag::Render(uchar* buffer, ID3_TagType tt) const{  ID3_MemoryWriter mw(buffer, -1);  return this->Render(mw, tt);}size_t ID3_Tag::Render(ID3_Writer& writer, ID3_TagType tt) const{  ID3_Writer::pos_type beg = writer.getCur();  if (ID3TT_ID3V2 & tt)  {    id3::v2::render(writer, *this);  }  else if (ID3TT_ID3V1 & tt)  {    id3::v1::render(writer, *this);  }  return writer.getCur() - beg;}/** Attaches a file to the tag, parses the file, and adds any tag information ** found in the file to the tag. ** ** Use this method if you created your ID3_Tag object without supplying a ** parameter to the constructor (maybe you created an array of ID3_Tag ** pointers).  This is the preferred method of interacting with files, since ** id3lib can automatically do things like parse foreign tag formats and ** handle padding when linked to a file.  When a tag is linked to a file, you ** do not need to use the Size(), Render(const uchar*, size_t), or ** Parse(ID3_Reader&) methods or the IsV2Tag(ID3_Reader&) static function-- ** id3lib will take care of those details for you.  The single parameter is a ** pointer to a file name. ** ** Link returns the size of the the ID3v2 tag (if any) that begins the file. ** ** \code **   ID3_Tag myTag; **   myTag.Link("mysong.mp3"); ** **   // do whatever we want with the tag **   // ... ** **   // setup all our rendering parameters **   myTag->SetUnsync(false); **   myTag->SetExtendedHeader(true); **   myTag->SetCompression(true); **   myTag->SetPadding(true); ** **   // write any changes to the file **   myTag->Update() ** ** \endcode ** ** @see IsV2Tag ** @param fileInfo The filename of the file to link to. **/size_t ID3_Tag::Link(const char *fileInfo, flags_t flags){  return _impl->Link(fileInfo, flags);}/** ** Same as above, but takes a ID3_Reader as argument. */size_t ID3_Tag::Link(ID3_Reader &reader, flags_t flags){  return _impl->Link(reader, flags);}flags_t ID3_Tag::Update(flags_t flags){  return _impl->Update(flags);}/** ** Get's the mp3 Info like bitrate, mpeg version, etc. ** Can be run after Link(<filename>) ** **/const Mp3_Headerinfo* ID3_Tag::GetMp3HeaderInfo() const{  return _impl->GetMp3HeaderInfo();}/** Strips the tag(s) from the attached file. The type of tag stripped ** can be specified as a parameter.  The default is to strip all tag types. ** ** \param tt The type of tag to strip ** \sa ID3_TagType **/flags_t ID3_Tag::Strip(flags_t flags){  return _impl->Strip(flags);}size_t ID3_Tag::GetPrependedBytes() const{  return _impl->GetPrependedBytes();}size_t ID3_Tag::GetAppendedBytes() const{  return _impl->GetAppendedBytes();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -