Results 1 to 3 of 3

Thread: MP3 Tags

  1. #1
    Join Date
    Jan 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default MP3 Tags

    Hi to everyone!
    I would need some advice on reading mp3 tags from mp3 files (ID3v1 for now-you have to walk before you fly!) but I can't find help anywhere! I'm fairly new to bot Qt and C++ but I consider myself a pretty quick learner in programming languages. I've been programming in VB.NET for the past three years, but now I see no option but to sharpen my teeth in C++ too!
    The question is pretty obvious: how do I read MP3 Tags?
    Here is the code for adding files in a tree widget (through an action):
    Qt Code:
    1. void wndMain::on_actAddFiles_triggered()//Add files
    2. {
    3. QString music_location=QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
    4. QStringList sFiles=QFileDialog::getOpenFileNames(this,tr("Add mp3 files..."),music_location,
    5. "Mp3 files (*.mp3)");
    6. //Check if something is selected
    7. if (sFiles.isEmpty())
    8. return;
    9. //If yes, add them to the list
    10. foreach (QString sFile,sFiles)
    11. {
    12. //setup an item
    13. QTreeWidgetItem *item=new QTreeWidgetItem(ui->trwLibrary);
    14. QFileInfo f(sFile);
    15. item->setText(0,f.fileName());
    16. item->setText(1,f.filePath());
    17. item->setText(2,QString::number(f.size()/1024)+" KB");
    18. item->setIcon(0,QIcon("icons/library/track.svg"));
    19. //Add item to list
    20. ui->trwLibrary->addTopLevelItem(item);
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 
    I've been thinking about a small piece of code in the foreach loop, to quickly read the tags and subsequently display them in the tree widget. I know that I have to extract the last 128 bytes of the file and then parse them to extract the tags from there, but I have no clue how to do this-and the documentation wasn't helpful at all!
    So, any help would be dearly appreciated.

    Last but not least, I'm running on Ubuntu 9.10, with Qt 4.6, Qt Creator 1.3.0.

  2. #2
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: MP3 Tags

    Hi,

    You can take a look to http://developer.kde.org/~wheeler/taglib.html, it works fine for me.

  3. #3
    Join Date
    Jan 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: MP3 Tags

    Thanks nix! I've already seen it! But this solution is huge and complicated for me! Not to mention that I would like to do it on my own!

Similar Threads

  1. Matching HTML tags
    By pucara_faa in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2010, 13:19
  2. Xml tags
    By mickey in forum General Discussion
    Replies: 1
    Last Post: 16th September 2009, 22:45
  3. Html tags in QTreeView
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2009, 01:41
  4. QFontMetrics and HTML tags
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 14th August 2008, 12:13
  5. Getting All Text Between Tags in XML ?
    By seanmu13 in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2007, 16:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.