Unsolved Best way to get Media MetaData?
-
@Pablo-J.-Rogina This project is actually a homework so I can't use external library
-
Hi,
What exactly are you allowed to use ?
-
@SGaist everything in QT, the point is I have to understand how to do it so external library is not allowed
-
@NguyenMinh said in Best way to get Media MetaData?:
QMediaPlayer in this funtion to read meta data but it too slow
Can you show how you're using it?
-
@jsulm I want to do it in a function so I try something like this:
void addSong(){ QMediaPlayer *player=new QMediaPlayer; player->setMedia(QUrl("C:/Users/Public/Music/Sample Music/music1.mp3")); QStringList metadatalist = player->availableMetaData(); qDebug()<<metadatalist; {
This will fail because setMedia take time to load the file so metadatalist will be a blank string.
-
@NguyenMinh Yes you can't do it like this. Qt is assynchronous.
Actually, you can use https://doc.qt.io/qt-5/qmediaobject.html
Connect a slot to https://doc.qt.io/qt-5/qmediaobject.html#availabilityChanged signal and read meta data there if parameter is true.
Maybe https://doc.qt.io/qt-5/qmediaobject.html#metaDataChanged is of interest as well. -
@jsulm thank you, I understand your solution but i have 1 more question:
Is it possible to using QMediaObject class or we have to use its subclass like QMediaPlayer? Is there any "cheaper" way? -
@NguyenMinh You can use QMediaObject directly as I suggested - should be cheap enough :-)
-
@jsulm but how? the QMediaObject's constructer is protected. And there's no function to set media content.
-
@NguyenMinh You're right. Looks like you have to use QMediaPlayer.