How to extract cover art from a media file using Qt Libraries

  • I'm trying to extract cover art from a media file.
    My application is QML Application. I have to feed the extracted cover image from media file from Qt to QML.

    I tried as following:
    @gui->setProperty("coverImage", (this->metaData("CoverArtImage")))@

    where this is QMediaPlayer class
    gui is QQuickItem
    coverImage is a string property in qml file.

    I'm giving this coverImage as source inside Image element.
    I came to know there is some conversion issue here, from Image to providing it as a string etc.
    When I tested this:
    @qDebug() << this->metaData("CoverArtImage").type();@

    it returned QVariant::Invalid

    How should I do this?

    Thanks & Regards,

  • Moderators

    What type of media file are you reading?
    Did you also try the CoverArtUrlSmall/CoverArtUrlLarge?
    Are you sure your media file has a cover-art embedded?

  • Im feeding mp3 files only. I'm sure few songs in my list have a Cover Art. Windows 8 music player app recognized them. If needed, I can give that song too for testing.

    Ya. I tried it.
    @qDebug() << this->metaData("CoverArtImage").type();
    qDebug() << this->metaData("CoverArtUrlLarge");
    qDebug() << this->metaData("CoverArtUrlSmall");@

    They too gave the same result.

    QVariant(Invalid) @

  • Anyone tried this???

  • Moderators

    [quote author="inblueswithu" date="1385402782"]I'm sure few songs in my list have a Cover Art. [/quote]
    Are you really sure? I'm asking because i wouldn't be surprised when the player just loads the coverart from the internet based on the artist and title provided. Use some tool which really reads the metadata from the media file (a quick google search came up with "this": for example)

    As a safe fall back i would recommend to use a free 3rd party lib for this. For example: "TagLib":

  • Ya. I have seen them before but failed to compile successfully. So, I chose to use default Qt libs.

    I didn't want to increase size of my application by adding these 3rd party libs. But it seems inevitable in my present situation.

Log in to reply

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