PDA

View Full Version : [QT5] QtMultimedia | i can`t get metadata



petrusPL
27th February 2013, 15:16
Hi :)
I try to get the meta data of music file (i try different files and udio formats mp3 wav etc) all files are good becaouse other players shows meta data :C
I try it on different ways but no one method work :/
my code:

testPlayer = new QMediaPlayer;
playList = new QMediaPlaylist;

testPlayer->setVolume(50);
// testPlayer->setMedia(QUrl::fromLocalFile("test2.mp3")); // try without playlist -> dont work :C
playList->addMedia(QUrl::fromLocalFile("test2.mp3"));
testPlayer->setPlaylist(playList);
playList->setCurrentIndex(0);
qDebug() << "Test: " << testPlayer->metaData(QMediaMetaData::Title);

connect(testPlayer, SIGNAL(metaDataChanged()), this, SLOT(stc()));

stc();


void MainWindow::stc()
{
qDebug() << testPlayer->isMetaDataAvailable();
if(testPlayer->isMetaDataAvailable())
{
qDebug() << testPlayer->metaData(QMediaMetaData::Duration);
}
}

and i always get result data

Test: QVariant(Invalid)
false
false
false
false

what i do wrong :C ?
please help :(