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

📄 misc_support.cpp

📁 更新mp3
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//following routine courtesy of John GeorgeID3_Frame* ID3_AddPicture(ID3_Tag* tag, const char* TempPicPath, const char* MimeType, bool replace){  ID3_Frame* frame = NULL;  if (NULL != tag )  {    if (replace)      ID3_RemovePictures(tag);    if (replace || NULL == tag->Find(ID3FID_PICTURE))    {      frame = new ID3_Frame(ID3FID_PICTURE);      if (NULL != frame)      {        frame->GetField(ID3FN_DATA)->FromFile(TempPicPath);        frame->GetField(ID3FN_MIMETYPE)->Set(MimeType);        tag->AttachFrame(frame);      }    }  }  return frame;}//following routine courtesy of John Georgesize_t ID3_RemovePictures(ID3_Tag* tag){  size_t num_removed = 0;  ID3_Frame* frame = NULL;  if (NULL == tag)    return num_removed;  while ((frame = tag->Find(ID3FID_PICTURE)))  {    frame = tag->RemoveFrame(frame);    delete frame;    num_removed++;  }  return num_removed;}//following routine courtesy of John Georgesize_t ID3_RemovePictureType(ID3_Tag* tag, ID3_PictureType pictype){  size_t bremoved = 0;  ID3_Frame* frame = NULL;  if (NULL == tag)    return bremoved;  ID3_Tag::Iterator* iter = tag->CreateIterator();  while (NULL != (frame = iter->GetNext()))  {    if (frame->GetID() == ID3FID_PICTURE)    {      if (frame->GetField(ID3FN_PICTURETYPE)->Get() == (uint32)pictype)        break;    }  }  delete iter;  if (NULL != frame)  {    frame = tag->RemoveFrame(frame);    delete frame;    bremoved = 1;  }  return bremoved;}//following routine courtesy of John GeorgeID3_Frame* ID3_AddPicture(ID3_Tag *tag, const char *TempPicPath, const char *MimeType, ID3_PictureType pictype, const char* Description, bool replace){  ID3_Frame* frame = NULL;  if (NULL != tag )  {    if (replace)      ID3_RemovePictureType(tag, pictype);    if (replace || NULL == tag->Find(ID3FID_PICTURE))    {      frame = new ID3_Frame(ID3FID_PICTURE);      if (NULL != frame)      {        frame->GetField(ID3FN_DATA)->FromFile(TempPicPath);        frame->GetField(ID3FN_MIMETYPE)->Set(MimeType);        frame->GetField(ID3FN_PICTURETYPE)->Set((uint32)pictype);        frame->GetField(ID3FN_DESCRIPTION)->Set(Description);        tag->AttachFrame(frame);      }    }  }  return frame;}//following routine courtesy of John Georgesize_t ID3_GetPictureDataOfPicType(ID3_Tag* tag, const char* TempPicPath, ID3_PictureType pictype){  if (NULL == tag)    return 0;  else  {    ID3_Frame* frame = NULL;    ID3_Tag::Iterator* iter = tag->CreateIterator();    while (NULL != (frame = iter->GetNext() ))    {      if(frame->GetID() == ID3FID_PICTURE)      {        if(frame->GetField(ID3FN_PICTURETYPE)->Get() == (uint32)pictype)          break;      }    }    delete iter;    if (frame != NULL)    {      ID3_Field* myField = frame->GetField(ID3FN_DATA);      if (myField != NULL)      {        myField->ToFile(TempPicPath);        return (size_t)myField->Size();      }      else return 0;    }    else return 0;  }}//following routine courtesy of John Georgechar* ID3_GetMimeTypeOfPicType(ID3_Tag* tag, ID3_PictureType pictype){  char* sPicMimetype = NULL;  if (NULL == tag)    return sPicMimetype;  ID3_Frame* frame = NULL;  ID3_Tag::Iterator* iter = tag->CreateIterator();  while (NULL != (frame = iter->GetNext()))  {    if(frame->GetID() == ID3FID_PICTURE)    {      if(frame->GetField(ID3FN_PICTURETYPE)->Get() == (uint32)pictype)        break;    }  }  delete iter;  if (frame != NULL)  {    sPicMimetype = ID3_GetString(frame, ID3FN_MIMETYPE);  }  return sPicMimetype;}//following routine courtesy of John Georgechar* ID3_GetDescriptionOfPicType(ID3_Tag* tag, ID3_PictureType pictype){  char* sPicDescription = NULL;  if (NULL == tag)    return sPicDescription;  ID3_Frame* frame = NULL;  ID3_Tag::Iterator* iter = tag->CreateIterator();  while (NULL != (frame = iter->GetNext()))  {    if(frame->GetID() == ID3FID_PICTURE)    {      if(frame->GetField(ID3FN_PICTURETYPE)->Get() == (uint32)pictype)        break;    }  }  delete iter;  if (frame != NULL)  {    sPicDescription = ID3_GetString(frame, ID3FN_DESCRIPTION);  }  return sPicDescription;}size_t ID3_RemoveTracks(ID3_Tag* tag){  size_t num_removed = 0;  ID3_Frame* frame = NULL;  if (NULL == tag)  {    return num_removed;  }  while ((frame = tag->Find(ID3FID_TRACKNUM)))  {    frame = tag->RemoveFrame(frame);    delete frame;    num_removed++;  }  return num_removed;}char *ID3_GetGenre(const ID3_Tag *tag){  char *sGenre = NULL;  if (NULL == tag)  {    return sGenre;  }  ID3_Frame *frame = tag->Find(ID3FID_CONTENTTYPE);  if (frame != NULL)  {    sGenre = ID3_GetString(frame, ID3FN_TEXT);  }  return sGenre;}size_t ID3_GetGenreNum(const ID3_Tag *tag){  char *sGenre = ID3_GetGenre(tag);  size_t ulGenre = 0xFF;  if (NULL == sGenre)  {    return ulGenre;  }  // If the genre string begins with "(ddd)", where "ddd" is a number, then  // "ddd" is the genre number---get it  if (sGenre[0] == '(')  {    char *pCur = &sGenre[1];    while (isdigit(*pCur))    {      pCur++;    }    if (*pCur == ')')    {      // if the genre number is greater than 255, its invalid.      ulGenre = dami::min(0xFF, atoi(&sGenre[1]));    }  }  delete [] sGenre;  return ulGenre;}//following routine courtesy of John GeorgeID3_Frame* ID3_AddGenre(ID3_Tag* tag, const char* genre, bool replace){  ID3_Frame* frame = NULL;  if (NULL != tag && NULL != genre && strlen(genre) > 0)  {    if (replace)    {      ID3_RemoveGenres(tag);    }    if (replace || NULL == tag->Find(ID3FID_CONTENTTYPE))    {      frame = new ID3_Frame(ID3FID_CONTENTTYPE);      if (NULL != frame)      {        frame->GetField(ID3FN_TEXT)->Set(genre);        tag->AttachFrame(frame);      }    }  }  return frame;}ID3_Frame* ID3_AddGenre(ID3_Tag *tag, size_t genreNum, bool replace){  if(0xFF != genreNum)  {    char sGenre[6];    sprintf(sGenre, "(%lu)", (luint) genreNum);    return(ID3_AddGenre(tag, sGenre, replace));  }  else  {    return(NULL);  }}size_t ID3_RemoveGenres(ID3_Tag *tag){  size_t num_removed = 0;  ID3_Frame *frame = NULL;  if (NULL == tag)  {    return num_removed;  }  while ((frame = tag->Find(ID3FID_CONTENTTYPE)))  {    frame = tag->RemoveFrame(frame);    delete frame;    num_removed++;  }  return num_removed;}char *ID3_GetLyrics(const ID3_Tag *tag){  char *sLyrics = NULL;  if (NULL == tag)  {    return sLyrics;  }  ID3_Frame *frame = tag->Find(ID3FID_UNSYNCEDLYRICS);  if (frame != NULL)  {    sLyrics = ID3_GetString(frame, ID3FN_TEXT);  }  return sLyrics;}ID3_Frame* ID3_AddLyrics(ID3_Tag *tag, const char *text, bool replace){  return ID3_AddLyrics(tag, text, "", replace);}ID3_Frame* ID3_AddLyrics(ID3_Tag *tag, const char *text, const char* desc,                         bool replace){  return ID3_AddLyrics(tag, text, desc, "XXX", replace);}ID3_Frame* ID3_AddLyrics(ID3_Tag *tag, const char *text, const char* desc,                         const char* lang, bool replace){  ID3_Frame* frame = NULL;  if (NULL != tag && strlen(text) > 0)  {    if (replace)    {      ID3_RemoveLyrics(tag);    }    if (replace || tag->Find(ID3FID_UNSYNCEDLYRICS) == NULL)    {      frame = new ID3_Frame(ID3FID_UNSYNCEDLYRICS);      if (NULL != frame)      {        frame->GetField(ID3FN_LANGUAGE)->Set(lang);        frame->GetField(ID3FN_DESCRIPTION)->Set(desc);        frame->GetField(ID3FN_TEXT)->Set(text);        tag->AttachFrame(frame);      }    }  }  return frame;}size_t ID3_RemoveLyrics(ID3_Tag *tag){  size_t num_removed = 0;  ID3_Frame *frame = NULL;  if (NULL == tag)  {    return num_removed;  }  while ((frame = tag->Find(ID3FID_UNSYNCEDLYRICS)))  {    frame = tag->RemoveFrame(frame);    delete frame;    num_removed++;  }  return num_removed;}char *ID3_GetLyricist(const ID3_Tag *tag){  char *sLyricist = NULL;  if (NULL == tag)  {    return sLyricist;  }  ID3_Frame *frame = tag->Find(ID3FID_LYRICIST);  if (frame != NULL)  {    sLyricist = ID3_GetString(frame, ID3FN_TEXT);  }  return sLyricist;}ID3_Frame* ID3_AddLyricist(ID3_Tag *tag, const char *text, bool replace){  ID3_Frame* frame = NULL;  if (NULL != tag && NULL != text && strlen(text) > 0)  {    if (replace)    {      ID3_RemoveLyricist(tag);    }    if (replace || (tag->Find(ID3FID_LYRICIST) == NULL))    {      frame = new ID3_Frame(ID3FID_LYRICIST);      if (frame)      {        frame->GetField(ID3FN_TEXT)->Set(text);        tag->AttachFrame(frame);      }    }  }  return frame;}size_t ID3_RemoveLyricist(ID3_Tag *tag){  size_t num_removed = 0;  ID3_Frame *frame = NULL;  if (NULL == tag)  {    return num_removed;  }  while ((frame = tag->Find(ID3FID_LYRICIST)))  {    frame = tag->RemoveFrame(frame);    delete frame;    num_removed++;  }  return num_removed;}ID3_Frame* ID3_AddSyncLyrics(ID3_Tag *tag, const uchar *data, size_t datasize,                             ID3_TimeStampFormat format, bool replace){  return ID3_AddSyncLyrics(tag, data, datasize, format, "", replace);}ID3_Frame* ID3_AddSyncLyrics(ID3_Tag *tag, const uchar *data, size_t datasize,                             ID3_TimeStampFormat format, const char *desc,                             bool replace){  return ID3_AddSyncLyrics(tag, data, datasize, format, desc, "XXX", replace);}ID3_Frame* ID3_AddSyncLyrics(ID3_Tag *tag, const uchar *data, size_t datasize,                             ID3_TimeStampFormat format, const char *desc,                             const char *lang, bool replace){  return ID3_AddSyncLyrics(tag, data, datasize, format, desc, lang,                           ID3CT_LYRICS, replace);}ID3_Frame* ID3_AddSyncLyrics(ID3_Tag *tag, const uchar *data, size_t datasize,                             ID3_TimeStampFormat format, const char *desc,                             const char *lang, ID3_ContentType type,                             bool replace){  ID3_Frame* frame = NULL;  // language and descriptor should be mandatory  if ((NULL == lang) || (NULL == desc))  {    return NULL;  }  // check if a SYLT frame of this language or descriptor already exists  ID3_Frame* frmExist = tag->Find(ID3FID_SYNCEDLYRICS, ID3FN_LANGUAGE, lang);  if (!frmExist)  {    frmExist = tag->Find(ID3FID_SYNCEDLYRICS, ID3FN_DESCRIPTION, desc);  }  if (NULL != tag && NULL != data)  {    if (replace && frmExist)    {      frmExist = tag->RemoveFrame (frmExist);      delete frmExist;      frmExist = NULL;    }    // if the frame still exist, cannot continue    if (frmExist)    {      return NULL;    }    ID3_Frame* frame = new ID3_Frame(ID3FID_SYNCEDLYRICS);    frame->GetField(ID3FN_LANGUAGE)->Set(lang);    frame->GetField(ID3FN_DESCRIPTION)->Set(desc);    frame->GetField(ID3FN_TIMESTAMPFORMAT)->Set(format);    frame->GetField(ID3FN_CONTENTTYPE)->Set(type);    frame->GetField(ID3FN_DATA)->Set(data, datasize);    tag->AttachFrame(frame);  }  return frame;}ID3_Frame *ID3_GetSyncLyricsInfo(const ID3_Tag *tag, const char *desc,                                 const char *lang,                                 ID3_TimeStampFormat& format,                                 ID3_ContentType& type, size_t& size){  // check if a SYLT frame of this language or descriptor exists  ID3_Frame* frmExist = NULL;  if (NULL != lang)  {    // search through language    frmExist = tag->Find(ID3FID_SYNCEDLYRICS, ID3FN_LANGUAGE, lang);  }  else if (NULL != desc)  {    // search through descriptor    frmExist = tag->Find(ID3FID_SYNCEDLYRICS, ID3FN_DESCRIPTION, desc);  }  else  {    // both language and description not specified, search the first SYLT frame    frmExist = tag->Find(ID3FID_SYNCEDLYRICS);  }  if (!frmExist)  {    return NULL;  }  // get the lyrics time stamp format  format = static_cast<ID3_TimeStampFormat>(frmExist->GetField(ID3FN_TIMESTAMPFORMAT)->Get ());  // get the lyrics content type  type = static_cast<ID3_ContentType>(frmExist->GetField(ID3FN_CONTENTTYPE)->Get ());  // get the lyrics size  size = frmExist->GetField (ID3FN_DATA)->Size ();  // return the frame pointer for further uses  return frmExist;}ID3_Frame *ID3_GetSyncLyrics(const ID3_Tag* tag, const char* lang,                              const char* desc, const uchar* &pData, size_t& size){  // check if a SYLT frame of this language or descriptor exists  ID3_Frame* frmExist = NULL;  if (NULL != lang)  {    // search through language    frmExist = tag->Find(ID3FID_SYNCEDLYRICS, ID3FN_LANGUAGE, lang);  }  else if (NULL != desc)  {    // search through descriptor    frmExist = tag->Find(ID3FID_SYNCEDLYRICS, ID3FN_DESCRIPTION, desc);  }  else  {    // both language and description not specified, search the first SYLT frame    frmExist = tag->Find(ID3FID_SYNCEDLYRICS);  }  if (NULL == frmExist)  {    return NULL;  }  // get the lyrics size  size = dami::min(size, frmExist->GetField(ID3FN_DATA)->Size());  // get the lyrics data  pData = frmExist->GetField (ID3FN_DATA)->GetRawBinary();  // return the frame pointer for further uses  return frmExist;}

⌨️ 快捷键说明

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