Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Using Qt Mobility to get metadata from media files

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on: Nokia 5800 XpressMusic
Platform(s): Qt 4.x
S60 5th Edition
Keywords: QMediaPlayer, QMediaObject
Created: User:Kbwiki (29 Jun 2010)
Last edited: hamishwillee (20 Nov 2012)


With the QMediaObject::availableMetaData() and QMediaObject::metaData() functions we can retrieve the metadata in a media file (audio/video). The metadata information can be only retrieved while the file is playing.

Qt Mobility APIs are included in the Qt SDK.


Define the QtMobility/Multimedia configuration in the .pro file:

  CONFIG += mobility
MOBILITY = multimedia

Header files:

  #include <QMediaPlayer>
#include <qtmedianamespace.h>


  // Use QMediaPlayer as a class member
QMediaPlayer *player;
// create the player and start playback
player = new QMediaPlayer(this);
player->setVolume( 25 );

A method to get the metadata of the media file:

  void MediaMetaDataExample::GetMetaData()
// Get the list of keys there is metadata available for
QList<QtMediaServices::MetaData> metadatalist = player->availableMetaData();
// Get the size of the list
int list_size = metadatalist.size();
// Define variables to store metadata key and value
QtMediaServices::MetaData metadata_key;
QVariant var_data;
for (int indx = 0; indx < list_size; indx++) {
// Get the key from the list
metadata_key =;
// Get the value for the key
var_data = player->metaData(metadata_key);
switch(metadata_key) {
case QtMediaServices::Title:
// Retrieve title (using var_data.toString())
case QtMediaServices::SubTitle:
// Retrieve subtitle
case QtMediaServices::Author:
// Retrieve author
// ... see QtMediaServices for rest of the values

A method to get the extended metadata of the media file:

  void MediaMetaDataExample::GetExtendedMetaData()
// Retrieve extended metadata key list
QStringList extn_metadata = player->availableExtendedMetaData();
int count_extn = extn_metadata.count();
QString extn_metadata_key;
QVariant extn_metadata_value;
for( int indx = 0; indx < count_extn; indx++ )
extn_metadata_key =;
extn_metadata_value = player->extendedMetaData(extn_metadata_key);
// Process extended metadata here
// Need to convert QVariant into proper type

This page was last modified on 20 November 2012, at 04:01.
93 page views in the last 30 days.