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();
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();
To copy to clipboard, switch view to plain text mode
void MainWindow::stc()
{
qDebug() << testPlayer->isMetaDataAvailable();
if(testPlayer->isMetaDataAvailable())
{
qDebug() << testPlayer->metaData(QMediaMetaData::Duration);
}
}
void MainWindow::stc()
{
qDebug() << testPlayer->isMetaDataAvailable();
if(testPlayer->isMetaDataAvailable())
{
qDebug() << testPlayer->metaData(QMediaMetaData::Duration);
}
}
To copy to clipboard, switch view to plain text mode
and i always get result data
Test: QVariant(Invalid)
false
false
false
false
what i do wrong :C ?
please help
Bookmarks