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
Code:
QList<Phonon::MediaSource> files;
to keep music files in my program. Now, I want to their metadata valuse like this:
Code:
mediaObject->setCurrentSource(files[index]);
QMap<QString, QString> metaData = mediaObject->metaData();
QString title
= metaData.
values("TITLE");
But it doesn't works...
Anybody know how to help my?
Re: Phonon and file's metadata
Quote:
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?
Re: Phonon and file's metadata
Well, We must emit a signal metaDataChanged(),it can get the information for title.
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:
Code:
localMediaObject.setCurrentSource(source);
connect(this, SIGNAL(xxx), &localMediaObject, SIGNAL(metaDataChanged()));
emit xxx();
if (!waitForMediaObjectToLoad(&localMediaObject, OneSecond))
return;
...
but that also didn't work. any pointers?
Re: Phonon and file's metadata
Code:
connect(localMediaObject, SIGNAL(metaDataChanged()), this, SLOT(yourfunction()));
Re: Phonon and file's metadata
Quote:
Originally Posted by
spinax
Code:
connect(localMediaObject, SIGNAL(metaDataChanged()), this, SLOT(yourfunction()));
i don't get it...i have just tried that exact same code:
Code:
localMediaObject = new Phonon::MediaObject(this);
Phonon::MediaSource source(filename);
connect(localMediaObject, SIGNAL(metaDataChanged()), this, SLOT(addTrack()));
localMediaObject->setCurrentSource(source);
but my addTrack method is never called :| thanks for replying anyway