How to use QMetaDataReaderControl to store available song metadata to QList<QStringList> while loading files from disk



  • Hi,

    How can I store available song metadata while loadin song file from disk? I don't know how to exactly use this Class, while initializing QMetaDataReaderControl, I'm getting this error:
    @
    ../qPlayer/mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':
    ../qPlayer/mainwindow.cpp:16:53: error: cannot allocate an object of abstract type 'QMetaDataReaderControl'
    metadataReader = new QMetaDataReaderControl(this);
    ^
    In file included from /usr/include/qt5/QtMultimedia/QMetaDataReaderControl:1:0,
    from ../qPlayer/mainwindow.h:11,
    from ../qPlayer/mainwindow.cpp:1:
    /usr/include/qt5/QtMultimedia/qmetadatareadercontrol.h:58:27: note: because the following virtual functions are pure within 'QMetaDataReaderControl':
    class Q_MULTIMEDIA_EXPORT QMetaDataReaderControl : public QMediaControl
    ^
    /usr/include/qt5/QtMultimedia/qmetadatareadercontrol.h:64:18: note: virtual bool QMetaDataReaderControl::isMetaDataAvailable() const
    virtual bool isMetaDataAvailable() const = 0;
    ^
    /usr/include/qt5/QtMultimedia/qmetadatareadercontrol.h:66:22: note: virtual QVariant QMetaDataReaderControl::metaData(const QString&) const
    virtual QVariant metaData(const QString &key) const = 0;
    ^
    /usr/include/qt5/QtMultimedia/qmetadatareadercontrol.h:67:25: note: virtual QStringList QMetaDataReaderControl::availableMetaData() const
    virtual QStringList availableMetaData() const = 0;
    @

    Another question: Is there a better way of storing songs metadata while loading them from disk? Or is there another way of displaying the song title, author etc. in a QTableWidget while loading the songs?

    Thanks.


  • Lifetime Qt Champion

    Hi,

    You can't use this class like that. Like the error said it's an abstract class. You can query it using "QMediaService::requestControl":http://doc.qt.io/qt-5/qmediaservice.html#requestControl


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.