00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <iostream>
00029 #include <stdio.h>
00030
00031 #include <fileref.h>
00032 #include <tag.h>
00033
00034 using namespace std;
00035
00036 TagLib::String formatSeconds(int seconds)
00037 {
00038 char secondsString[3];
00039 sprintf(secondsString, "%02i", seconds);
00040 return secondsString;
00041 }
00042
00043 int main(int argc, char *argv[])
00044 {
00045 for(int i = 1; i < argc; i++) {
00046
00047 cout << "******************** \"" << argv[i] << "\" ********************" << endl;
00048
00049 TagLib::FileRef f(argv[i]);
00050
00051 if(!f.isNull() && f.tag()) {
00052
00053 TagLib::Tag *tag = f.tag();
00054
00055 cout << "-- TAG --" << endl;
00056 cout << "title - " << tag->title() << endl;
00057 cout << "artist - " << tag->artist() << endl;
00058 cout << "album - " << tag->album() << endl;
00059 cout << "year - " << tag->year() << endl;
00060 cout << "comment - " << tag->comment() << endl;
00061 cout << "track - " << tag->track() << endl;
00062 cout << "genre - " << tag->genre() << endl;
00063 }
00064
00065 if(!f.isNull() && f.audioProperties()) {
00066
00067 TagLib::AudioProperties *properties = f.audioProperties();
00068
00069 int seconds = properties->length() % 60;
00070 int minutes = (properties->length() - seconds) / 60;
00071
00072 cout << "-- AUDIO --" << endl;
00073 cout << "bitrate - " << properties->bitrate() << endl;
00074 cout << "sample rate - " << properties->sampleRate() << endl;
00075 cout << "channels - " << properties->channels() << endl;
00076 cout << "length - " << minutes << ":" << formatSeconds(seconds) << endl;
00077 }
00078 }
00079 return 0;
00080 }