Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
  for(int i = 1; i < argc; i++) {

    cout << "path:" << argv[i] << endl;

    TagLib::FileRef f(argv[i]);

    if(!f.isNull() && f.tag()) {

      TagLib::Tag *tag = f.tag();

      cout << "title:" << (tag->title()).toCString(true)   << endl;
      cout << "artist:" << (tag->artist()).toCString(true) << endl;
      cout << "album:" << (tag->album()).toCString(true)   << endl;
      cout << "albumartist:" << (tag->albumArtist()).toCString(true) << endl;
      cout << "track:" << tag->track() << endl;
      cout << "disc:"  << tag->cdNr() << endl;
    }

    if(!f.isNull() && f.audioProperties()) {

      TagLib::AudioProperties *properties = f.audioProperties();

      cout << "bitrate:" << properties->bitrate() << endl;
      cout << "length:" << properties->length()  << endl;
    }
  if(i!=argc-1)
    cout << "---" << endl;
  }
  return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
  for(int i = 1; i < argc; i++) {

    cout << "******************** \"" << argv[i] << "\" ********************" << endl;

    TagLib::FileRef f(argv[i]);

    if(!f.isNull() && f.tag()) {

      TagLib::Tag *tag = f.tag();

      cout << "-- TAG --" << endl;
      cout << "title        - \"" << tag->title()   << "\"" << endl;
      cout << "artist       - \"" << tag->artist()  << "\"" << endl;
      cout << "album artist - \"" << tag->albumArtist()   << "\"" << endl;
      cout << "album        - \"" << tag->album()   << "\"" << endl;
      cout << "year         - \"" << tag->year()    << "\"" << endl;
      cout << "comment      - \"" << tag->comment() << "\"" << endl;
      cout << "track        - \"" << tag->track()   << "\"" << endl;
      cout << "genre        - \"" << tag->genre()   << "\"" << endl;
      cout << "grouping     - \"" << tag->grouping()   << "\"" << endl;
      TagLib::Ogg::XiphComment *comment = NULL;
      TagLib::FLAC::File *flac = dynamic_cast<TagLib::FLAC::File *>(f.file());
      if (flac) {
        cout << "flac:" << endl;
        cout << "id3v1   - \"" << flac->ID3v1Tag()   << "\"" << endl;
        cout << "id3v2   - \"" << flac->ID3v2Tag()   << "\"" << endl;
        cout << "xiph    - \"" << flac->xiphComment()   << "\"" << endl;
        comment = flac->xiphComment();
      }
      if (!comment) {
        comment = dynamic_cast<TagLib::Ogg::XiphComment *>(tag);
      }
      if (comment) {
        TagLib::Ogg::FieldListMap fields = comment->fieldListMap();
        for(TagLib::Ogg::FieldListMap::ConstIterator it = fields.begin(), end = fields.end(); it != end; it++) {
          if (!it->second.isEmpty())
            cout << "xiph:" << it->first << " \"" << it->second[0].substr(0,3) << "\"" << endl;
        }
      }
      cout << "pictures- \"" << f.file()->pictures().size()   << "\"" << endl;
      TagLib::File::PictureList l = f.file()->pictures();
      for (TagLib::File::_PictureList::ConstIterator i = l.begin(), end = l.end(); i != end; i++) {
        cout << "\t" << (*i)->typeName() << ' ' << (*i)->mimeType() << ' ' << (*i)->base64data().size() << endl;
      }
      
      cout << "pictures- \"" << tag->pictures().size()   << "\"" << endl;
    }

    if(!f.isNull() && f.audioProperties()) {

      TagLib::AudioProperties *properties = f.audioProperties();

      int seconds = properties->length() % 60;
      int minutes = (properties->length() - seconds) / 60;

      cout << "-- AUDIO --" << endl;
      cout << "bitrate     - " << properties->bitrate() << endl;
      cout << "sample rate - " << properties->sampleRate() << endl;
      cout << "channels    - " << properties->channels() << endl;
      cout << "length      - " << minutes << ":" << formatSeconds(seconds) << endl;
    }
  }
  return 0;
}