How to get the Metadata of songs played in MusicPlayer in Qml

983 views Asked by At

I am trying to get and display the metaData.coverArtUrlSmall from a mp3 file in qml. Song is playing fine but the metadata is not printing

I tried something like this

MediaPlayer {
    id: player
    onSourceChanged:
    {
        console.log("graphic " +metaData.coverArtUrlSmall);

    }
}

It prints qml: graphic undefined

Is there any way we could get the metadata of songs in qml

1

There are 1 answers

0
Mohammad Kanan On

For reference, in order to get metadata information, a metaData object is needed, for which the onMetaDataChanged is guaranteed to report back meta data information. Looking at sample code, this needs to be:

MediaPlayer {
    id: player
    metaData.onMetaDataChanged:
    {
        console.log("graphic " +metaData.coverArtUrlSmall);

    }
}