当前位置: 首页>>代码示例>>C++>>正文


C++ Tag::frameList方法代码示例

本文整理汇总了C++中taglib::id3v2::Tag::frameList方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::frameList方法的具体用法?C++ Tag::frameList怎么用?C++ Tag::frameList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taglib::id3v2::Tag的用法示例。


在下文中一共展示了Tag::frameList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ScanDirectory

Json::Value Firnplayer::ScanDirectory(const std::string &Root)
{
  // Initializations
  DIR *dir;
  struct dirent *ent;
  std::list<std::string> DirectoryQueue;
  Json::Value AllJson;

  // Push the root to the queue and start the scan loop
  DirectoryQueue.push_back(Root);
  while(DirectoryQueue.size()){
    // Grap the front of the queue and erase it from the queue
    std::string ThisDirectory = *DirectoryQueue.begin();
    DirectoryQueue.erase(DirectoryQueue.begin());
    if((dir = opendir(ThisDirectory.c_str())) != NULL) {  // Try to open the directory
      while ((ent = readdir(dir)) != NULL) {
        // First, see if it is a directory.  If so, we add id to the queue for later scans.
        if(ent->d_type == 4 && *ent->d_name != '.')
          DirectoryQueue.push_back(cleanpath(ThisDirectory + "/" + ent->d_name));
        else{
          // If it is not a queue, we look closer at the file.
          // First, we want to see if it has the .mp3 ending.
          std::string FileName = cleanpath(ThisDirectory + "/" + ent->d_name);
          std::string LastFour("    ");
          std::transform(FileName.begin()+(FileName.size()-4), FileName.end(), LastFour.begin(), ::toupper);
          if(LastFour == ".MP3")
          {
            // Ok, it calls itself an mp3.  Scan it!
            Json::Value &TrackJson = (AllJson[FileName] = Json::Value());
            TagLib::MPEG::File file(FileName.c_str());
            // If it has an ID3v2Tag, we use that.
            if(file.hasID3v2Tag())
            {
              TagLib::ID3v2::Tag *tag = file.ID3v2Tag(true);
              for(TagLib::List<TagLib::ID3v2::Frame *>::ConstIterator theitr = tag->frameList().begin(); theitr != tag->frameList().end(); theitr++)
              {
                std::string framevalue = (*theitr)->toString().to8Bit();
                std::string Trigger((*theitr)->frameID().data());
                Trigger = std::string(Trigger.begin(), Trigger.begin()+4);
                TrackJson[Trigger] = framevalue;
              }
            }
            // Now save the file path, the bitrate and the track length.
            TrackJson["FILE"] = FileName;
            TagLib::MPEG::Properties *Properties = file.audioProperties();
            TrackJson["LENG"] = Properties->length();
            TrackJson["BITR"] = Properties->bitrate();
          }
        }
      }
    }
  }
  return AllJson;
}
开发者ID:firngrod,项目名称:firnplayer,代码行数:54,代码来源:MetaData.cpp


注:本文中的taglib::id3v2::Tag::frameList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。