Congratulations to our 2022 Qt Champions!

ID3v1 or ID3v2 reading by using QFile on Mp3 files

  • Hello,

    İ wanna read mp3 files' ide tags by using Qfile. i read some article about last 128 bytes of mp3 is about ide tags but i couldnt see amy example about it.

    I saw about pragma, taglib, ide3tag etc.. but they are complex and not my wish;

    so than i tried to get some info from mp3 files by using that code

    QStringList sFiles=QFileDialog::getOpenFileNames(this,tr("Add mp3 files..."),"D:/test",
    "Mp3 files (*.mp3)");
    //Check if something is selected
    if (sFiles.isEmpty())
    //If yes, add them to the list
    foreach (QString sFile,sFiles)
    //setup an item
    QTreeWidgetItem *item=new QTreeWidgetItem(ui->trwLibrary);
    QFileInfo f(sFile);
    item->setText(3,QString::number(f.size()/1024)+" KB");
    //Add item to list

    but i doesnt worked, i could only take file name no others and it is not my wish

    i wanna take song name artist genre etc..

    is there anyone can show me a simple way to get these datas from mp3?

    thanks for your ideas.

    best wishes.

  • @kybernetes You can use a 3rd party library to do this. I suggest taking a look at the guide on how to use id3lib with Qt. Basically it shows you how to add id3lib to your project.