Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] reading ID3 tags from MP3 files
Forum Updated to NodeBB v4.3 + New Features

[Solved] reading ID3 tags from MP3 files

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tyras
    wrote on last edited by
    #1

    Hello everyone!

    I'm trying to do a mp3 files organizer, (My collection is all messed up), but I'm having problems to read the ID3 tags from the mp3 files.

    I'm using the code below to read the tags and move the files to the correct directories, but the methods always returns empty strings!

    While studing the API documentation, i found that I needed to wait the state changes to StoppedState, but it never changes. As you can see, i commented the line tthat waits until its changed because it locks the code at that point and never gets out.

    I've searched for some time, and find no solution. Can anyone help me?

    Thanks in Advance!

    @
    void Organizer::tratarMp3(Phonon::MediaObject *arquivo, QString dirRaiz, QString filePath){
    QMultiMap<QString, QString> tags;
    QDir dir(dirRaiz);

     //  while(temp.state()!=Phonon::StoppedState);
    
    tags = arquivo->metaData();
    
    if(tags.value("ARTIST").isEmpty()){
        dirRaiz.append("Outras/");
    }
    
    else{
        dirRaiz.append(tags.value("ARTIST"));
        dirRaiz.append("/");
    }
    
    if(!tags.value("ALBUM").isEmpty()){
        dirRaiz.append(tags.value("ALBUM"));
        dirRaiz.append("/");
    }
    
    else{
        dirRaiz.append("Outras/");
    }
    
    dir.setPath(dirRaiz);
    
    if(!dir.exists())
        dir.mkpath(dir.path());
    
    dirRaiz.append(arquivo->currentSource().fileName());
    
    QFile::copy(filePath,dirRaiz);
    
    //QFile::remove(arquivo.filePath());
    

    }
    @

    When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Ramblurr
      wrote on last edited by
      #2

      That busy loop locks the thread, and prevents any QEvents from being handled by the event loop.

      You should signals and slots to detect changes in Phonon's state.

      Create a slot and connect it to "MediaObject::stateChanged":http://doc.qt.nokia.com/latest/phonon-mediaobject.html#stateChanged, then inside that slot determine whether you can call tratarMp3().

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tyras
        wrote on last edited by
        #3

        Sorry for taking so long to post a reply! It worked, but i ended up using the Taglib libraries to support more formats. Thanks for the Help!

        When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved