目前常見的標示有ID3v1, ID3v2.3, ID3v2.4
讀取方式大同小異但在v1和v2.3的編碼方式為Big5所以讀取時要比較注意一點
關於各欄位資訊可參照Wikipedia
http://en.wikipedia.org/wiki/ID3
下面提供簡單的讀取範例
QFile *file=new QFile(MP3檔案路徑);
if (!file->open(QIODevice::ReadOnly))
{
qDebug()<<"return";
return;
}
QTextCodec *codec = QTextCodec::codecForName("Big5");
QString head = file->read(3);
QString sver = file->read(1);
int ver = sver.at(0).toAscii();
//移到倒數第128個位置
file->seek(file->size()-128);
QString tag = file->read(3);
qDebug()<<"tag"<
QString title = codec->toUnicode(file->read(30));
QString artist = codec->toUnicode(file->read(30));
QString album = codec->toUnicode(file->read(30));
QString year = codec->toUnicode(file->read(4));
QString comment = codec->toUnicode(file->read(30));
qDebug()<<"head"<
沒有留言:
張貼留言