- Qt 6.12
- Qt Multimedia
- C++ Classes
- QtMultimedia
- QMediaMetaData
- Qt 6.12.0 Reference Documentation

# QMediaMetaData Class

Provides meta-data for media files. More...

Header: | `#include <QMediaMetaData>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Multimedia)` `target_link_libraries(mytarget PRIVATE Qt6::Multimedia)`
qmake: | `QT += multimedia`

- List of all members, including inherited members

## Public Types

enum | Key { Title, Author, Comment, Description, Genre, …, HasHdrContent }

## Public Functions

`(since 6.9)` auto | asKeyValueRange() const
void | clear()
void | insert(QMediaMetaData::Key k, const QVariant &value)
bool | isEmpty() const
QList<QMediaMetaData::Key> | keys() const
void | remove(QMediaMetaData::Key k)
QString | stringValue(QMediaMetaData::Key key) const
QVariant | value(QMediaMetaData::Key key) const
QVariant & | operator[](QMediaMetaData::Key k)

## Static Public Members

QString | metaDataKeyToString(QMediaMetaData::Key key)

## Protected Variables

QHash<QMediaMetaData::Key, QVariant> | data

## Static Protected Members

QMetaType | keyType(QMediaMetaData::Key key)

## Related Non-Members

bool | operator!=(const QMediaMetaData &a, const QMediaMetaData &b)
bool | operator==(const QMediaMetaData &a, const QMediaMetaData &b)

## Detailed Description

Note: Not all identifiers are supported on all platforms.

Common attributes
Value | Description | Type
--- | --- | ---
Title | The title of the media. | QString
Author | The authors of the media. | QStringList
Comment | A user comment about the media. | QString
Description | A description of the media. | QString
Genre | The genre of the media. | QStringList
Date | The recording datetime of the media file, or the encoding datetime of the media stream. | QDateTime.
Language | The language of media. | QLocale::Language
Publisher | The publisher of the media. | QString
Copyright | The media's copyright notice. | QString
Url | A Url pointing to the origin of the media. | QUrl
Media attributes
MediaType | The type of the media (audio, video, etc). | QString
FileFormat | The file format of the media. | QMediaFormat::FileFormat
Duration | The duration in milliseconds of the media. | qint64
Audio attributes
AudioBitRate | The bit rate of the media's audio stream in bits per second. | int
AudioCodec | The codec of the media's audio stream. | QMediaFormat::AudioCodec
Video attributes
VideoFrameRate | The frame rate of the media's video stream. | qreal
VideoBitRate | The bit rate of the media's video stream in bits per second. | int
VideoCodec | The codec of the media's video stream. | QMediaFormat::VideoCodec
HasHdrContent | True if video is intended for HDR display (FFmpeg and Darwin media backends only). | bool
Music attributes
AlbumTitle | The title of the album the media belongs to. | QString
AlbumArtist | The principal artist of the album the media belongs to. | QString
ContributingArtist | The artists contributing to the media. | QStringList
TrackNumber | The track number of the media. | int
Composer | The composer of the media. | QStringList
LeadPerformer | The lead performer in the media. | QStringList
CoverArtImage | An embedded cover art image. | QImage
ThumbnailImage | An embedded thumbnail image. (deprecated since 6.12, use CoverArtImage instead) | QImage
Image and video attributes
Orientation | The rotation angle of an image or video. | int
Resolution | The dimensions of an image or video. | QSize

## Member Type Documentation

### enum QMediaMetaData::Key

The following meta data keys can be used:

Constant | Value | Description
--- | --- | ---
`QMediaMetaData::Title` | `0` | Media title
`QMediaMetaData::Author` | `1` | Media author
`QMediaMetaData::Comment` | `2` | Comment
`QMediaMetaData::Description` | `3` | Brief desripttion
`QMediaMetaData::Genre` | `4` | Genre the media belongs to
`QMediaMetaData::Date` | `5` | Creation date
`QMediaMetaData::Language` | `6` | Media language
`QMediaMetaData::Publisher` | `7` | Media publisher info.
`QMediaMetaData::Copyright` | `8` | Media copyright info.
`QMediaMetaData::Url` | `9` | Publisher's website URL
`QMediaMetaData::Duration` | `10` | Media playback duration
`QMediaMetaData::MediaType` | `11` | Type of the media
`QMediaMetaData::FileFormat` | `12` | File format
`QMediaMetaData::AudioBitRate` | `13` |
`QMediaMetaData::AudioCodec` | `14` |
`QMediaMetaData::VideoBitRate` | `15` |
`QMediaMetaData::VideoCodec` | `16` |
`QMediaMetaData::VideoFrameRate` | `17` |
`QMediaMetaData::AlbumTitle` | `18` | Album's title
`QMediaMetaData::AlbumArtist` | `19` | Artist's info.
`QMediaMetaData::ContributingArtist` | `20` |
`QMediaMetaData::TrackNumber` | `21` |
`QMediaMetaData::Composer` | `22` | Media composer's info.
`QMediaMetaData::LeadPerformer` | `23` |
`QMediaMetaData::ThumbnailImage` | `24` | Media thumbnail image (deprecated since 6.12, identical to CoverArtImage for backwards compatibility)
`QMediaMetaData::CoverArtImage` | `LeadPerformer + 2` | Media cover art
`QMediaMetaData::Orientation` | `26` |
`QMediaMetaData::Resolution` | `27` |
`QMediaMetaData::HasHdrContent (since Qt 6.8)` | `28` | Video may have HDR content (read only, FFmpeg and Darwin media backends only)

## Member Function Documentation

### `[since 6.9]` auto QMediaMetaData::asKeyValueRange() const

Returns a range object that allows iteration over this hash as key/value pairs.

This function was introduced in Qt 6.9.

### `[invokable]` void QMediaMetaData::clear()

Removes all data from the meta data object.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void QMediaMetaData::insert(QMediaMetaData::Key k, const QVariant &value)

Inserts a value into a Key: k.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` bool QMediaMetaData::isEmpty() const

Returns `true` if the meta data contains no items: otherwise returns `false`.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[static protected]` QMetaType QMediaMetaData::keyType(QMediaMetaData::Key key)

Returns the meta type used to store data for Key key.

### `[invokable]` QList<QMediaMetaData::Key> QMediaMetaData::keys() const

Returns a QList of QMediaMetaData::Keys.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[static invokable]` QString QMediaMetaData::metaDataKeyToString(QMediaMetaData::Key key)

returns a string representation of key that can be used when presenting meta data to users.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void QMediaMetaData::remove(QMediaMetaData::Key k)

Removes meta data from a Key: k.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` QString QMediaMetaData::stringValue(QMediaMetaData::Key key) const

Returns the meta data for key key as a QString.

This is mainly meant to simplify presenting the meta data to a user.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` QVariant QMediaMetaData::value(QMediaMetaData::Key key) const

Returns the meta data value for Key key, or a null QVariant if no meta data for the key is available.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### QVariant &QMediaMetaData::operator[](QMediaMetaData::Key k)

Returns data stored at the Key k.

     QMediaMetaData rockBallad1;
     rockBalad[QMediaMetaData::Genre]="Rock"

## Member Variable Documentation

### QHash<QMediaMetaData::Key, QVariant> QMediaMetaData::data

This variable holds the meta data.

Note: this is a `protected` member of its class.

## Related Non-Members

### bool operator!=(const QMediaMetaData &a, const QMediaMetaData &b)

Compares two meta data objects a and b, and returns `false` if they are identical or `true` if they differ.

### bool operator==(const QMediaMetaData &a, const QMediaMetaData &b)

Compares two meta data objects a and b, and returns `true` if they are identical or `false` if they differ.