Exemplo n.º 1
0
size_t ID3_GetGenreNum(const ID3_Tag *tag)
{
  char *sGenre = ID3_GetGenre(tag);
  size_t ulGenre = 0xFF;
  if (NULL == sGenre)
  {
    return ulGenre;
  }

  // If the genre string begins with "(ddd)", where "ddd" is a number, then 
  // "ddd" is the genre number---get it
  if (sGenre[0] == '(')
  {
    char *pCur = &sGenre[1];
    while (isdigit(*pCur))
    {
      pCur++;
    }
    if (*pCur == ')')
    {
      // if the genre number is greater than 255, its invalid.
      ulGenre = MIN(0xFF, atoi(&sGenre[1]));
    }
  }

  delete [] sGenre;
  return ulGenre;
}
Exemplo n.º 2
0
void Tag::parse() {
  char *str;

  if ((str = ID3_GetArtist(&tag)) != NULL)
    artist = str;

  if ((str = ID3_GetAlbum(&tag)) != NULL)
    album = str;

  if ((str = ID3_GetTitle(&tag)) != NULL)
    title = str;

  if ((str = ID3_GetGenre(&tag)) != NULL)
    genre = str;

  /*
  if (ID3_HasPicture(&tag)) {
    char picPath[1024] = "pic.tmp";

    ID3_Frame* frame = NULL;
    frame = tag.Find(ID3FID_PICTURE);
    if (frame != NULL)
    {
      ID3_Field* myField = frame->GetField(ID3FN_DATA);
      if (myField != NULL)
      {
	myField->ToFile(picPath);
	qWarning("writing file: %s (size=%d)",picPath, myField->Size());
      }
    }

    //    ID3_GetPictureData(&tag, picPath);
    //    picture.load(picPath);
    //    qWarning("loaded picture: %dx%d", picture.width(), picture.height());
  }
  */
}
Exemplo n.º 3
0
void MainWindow::on_pushButton_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), "", tr("Audio Files (*.mp3);"));
    flag = false;
    if (fileName.isEmpty() == false) {
        myTag.Link(fileName.toStdString().c_str());

        ui->tableWidget->setItem(0, 0, new QTableWidgetItem(QString::fromLocal8Bit(ID3_GetTitle(&myTag))));
        ui->tableWidget->setItem(0, 1, new QTableWidgetItem(QString::fromLocal8Bit(ID3_GetArtist(&myTag))));
        ui->tableWidget->setItem(0, 2, new QTableWidgetItem(QString::fromLocal8Bit(ID3_GetAlbum(&myTag))));
        ui->tableWidget->setItem(0, 3, new QTableWidgetItem(QString::fromLocal8Bit(ID3_GetYear(&myTag))));
        ui->tableWidget->setItem(0, 4, new QTableWidgetItem(QString::fromLocal8Bit(ID3_GetGenre(&myTag))));

        const Mp3_Headerinfo* mp3info;
        mp3info = myTag.GetMp3HeaderInfo();
        if (mp3info) {
            ui->tableWidget->setItem(0, 5, new QTableWidgetItem(QString::number(mp3info->bitrate/1000) + " KBps"));
            ui->tableWidget->setItem(0, 6, new QTableWidgetItem(QString::number(mp3info->frequency/1000) + " KHz"));
            ui->tableWidget->setItem(0, 7, new QTableWidgetItem(QString::number(mp3info->time/60) + " min " + QString::number(mp3info->time%60) + " s"));
        }
        flag = true;
    }

}