PDA

View Full Version : How to get Meta Data using QMediaPlayer ?



adutzu89
21st October 2015, 21:59
Can someone help me with a issue?
I am trying to get the meta data (for cross-platform portability reasons) using QMediaPlayer but with no avail.

I have changed the code to check if meta data is available but it returns false everytime here is the code from my method:

void ControlClass::get_file_data(const QString &path){
QFileInfo fi(path);
QString filePath = fi.filePath().remove(QRegExp("file://")); /* path returns the path and file:// prepended so I need to remove it to access the file properly */

QMediaPlayer *p = new QMediaPlayer(0);
p->setMedia(QUrl::fromLocalFile(filePath));
p->setVolume(100);
p->play();
qDebug()<<p->isMetaDataAvailable(); /* returns false */
}

The file plays but no metadata available for every song I played, any solutions?