Results 1 to 6 of 6

Thread: Phonon and file's metadata

  1. #1
    Join Date
    Apr 2010
    Location
    Rzeszów \ Poland
    Posts
    26
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Phonon and file's metadata

    Hello.
    I want to create a simple music player based on phonon libraries.
    In my GUI I've a tablewidget. It's working at music list.
    But I don't know how to read values ARTIST or TITLE from files metadata to take it to tablewidget after "open files" operation.

    I've a
    Qt Code:
    1. QList<Phonon::MediaSource> files;
    To copy to clipboard, switch view to plain text mode 
    to keep music files in my program. Now, I want to their metadata valuse like this:
    Qt Code:
    1. mediaObject->setCurrentSource(files[index]);
    2. QMap<QString, QString> metaData = mediaObject->metaData();
    3. QString title = metaData.values("TITLE");
    To copy to clipboard, switch view to plain text mode 

    But it doesn't works...

    Anybody know how to help my?
    Last edited by matulik; 30th March 2011 at 23:04.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Phonon and file's metadata

    Note that meta data is not resolved before the metaDataChanged() signal is emitted.
    Did you make sure that you code metadata code runs after metaDataChanged() was emitted?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Phonon and file's metadata

    Well, We must emit a signal metaDataChanged(),it can get the information for title.

  4. #4
    Join Date
    May 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Phonon and file's metadata

    hi!

    i seem to be having kinda the same problem...did you ever get it to work? i own the book 'advanced qt programming' which has a code example showing how to get metadata from files, but also that doesn't work the only way i could read metadata from the mediaObject so far, is, if i call mediaObject->play(); and in the slot handling the emitted stateChanged signal do mediaObject->metaData(), then mediaObject->stop().

    the example code has a timer waiting for 1 second for the stateChanged(Phonon::State, Phonon::State) signal after mediaObject.setCurrentSource(source);, but it seems like it is never emitted. could this be a bug in Phonon or am i misunderstandig the way this should work?

    in my desparation i even tried:
    Qt Code:
    1. localMediaObject.setCurrentSource(source);
    2. connect(this, SIGNAL(xxx), &localMediaObject, SIGNAL(metaDataChanged()));
    3. emit xxx();
    4. if (!waitForMediaObjectToLoad(&localMediaObject, OneSecond))
    5. return;
    6. ...
    To copy to clipboard, switch view to plain text mode 
    but that also didn't work. any pointers?
    Last edited by brezel; 9th May 2012 at 14:59.

  5. #5
    Join Date
    Apr 2012
    Location
    Poland
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Phonon and file's metadata

    Qt Code:
    1. connect(localMediaObject, SIGNAL(metaDataChanged()), this, SLOT(yourfunction()));
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    May 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Phonon and file's metadata

    Quote Originally Posted by spinax View Post
    Qt Code:
    1. connect(localMediaObject, SIGNAL(metaDataChanged()), this, SLOT(yourfunction()));
    To copy to clipboard, switch view to plain text mode 
    i don't get it...i have just tried that exact same code:
    Qt Code:
    1. localMediaObject = new Phonon::MediaObject(this);
    2. Phonon::MediaSource source(filename);
    3. connect(localMediaObject, SIGNAL(metaDataChanged()), this, SLOT(addTrack()));
    4. localMediaObject->setCurrentSource(source);
    To copy to clipboard, switch view to plain text mode 
    but my addTrack method is never called :| thanks for replying anyway

Similar Threads

  1. Phonon handling mp3 metadata
    By Baasie in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2010, 20:52
  2. Reading audio AND video metadata from files (Phonon?)
    By garfunkel in forum Qt Programming
    Replies: 0
    Last Post: 1st March 2010, 07:32
  3. Inserting PDF metadata
    By Randria in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2009, 10:18
  4. is qt phonon can read realmedia file and divx file
    By fayssalqt in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2009, 15:42
  5. Specifying method metadata
    By brcain in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 01:07

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
  •  
Qt is a trademark of The Qt Company.