本文整理汇总了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;
}