I want to get album art image from mp3 files
-
Does the documentation example show it properly ?
-
@SGaist ```
if (key == QMediaMetaData::CoverArtImage) {
270 QVariant v = metaData.value(key);
271 if (QLabel cover = qobject_cast<QLabel>(m_metaDataFields[key])) {
272 QImage coverImage = v.value<QImage>();
273 cover->setPixmap(QPixmap::fromImage(coverImage));
274 }This is part of example source code...
-
That was not my question.
The question was whether when you run the example, it shows the image for the file you are trying to load with your own application. -
That was not my question.
The question was whether when you run the example, it shows the image for the file you are trying to load with your own application. -
That was not my question.
The question was whether when you run the example, it shows the image for the file you are trying to load with your own application. -
So compare your code with the example to find the difference that makes yours fail.
-
I am not sure to follow you. It works on your desktop but not on Android ?
-
@SGaist said in I want to get album art image from mp3 files:
I am not sure to follow you. It works on your desktop but not on Android ?
void Player::metaDataChanged() { auto metaData = m_player->metaData(); setTrackInfo(QString("%1 - %2") .arg(metaData.value(QMediaMetaData::AlbumArtist).toString()) .arg(metaData.value(QMediaMetaData::Title).toString())); #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) for (int i = 0; i < QMediaMetaData::NumMetaData; i++) { if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[i])) field->clear(); else if (QLabel *label = qobject_cast<QLabel *>(m_metaDataFields[i])) label->clear(); m_metaDataFields[i]->setDisabled(true); m_metaDataLabels[i]->setDisabled(true); } for (auto &key : metaData.keys()) { int i = int(key); if (key == QMediaMetaData::CoverArtImage) { QVariant v = metaData.value(key); if (QLabel *cover = qobject_cast<QLabel *>(m_metaDataFields[key])) { QImage coverImage = v.value<QImage>(); cover->setPixmap(QPixmap::fromImage(coverImage)); } } else if (key == QMediaMetaData::ThumbnailImage) { QVariant v = metaData.value(key); if (QLabel *thumbnail = qobject_cast<QLabel *>(m_metaDataFields[key])) { QImage thumbnailImage = v.value<QImage>(); thumbnail->setPixmap(QPixmap::fromImage(thumbnailImage)); } } else if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[key])) { QString stringValue = metaData.stringValue(key); field->setText(stringValue); } m_metaDataFields[i]->setDisabled(false); m_metaDataLabels[i]->setDisabled(false); } #endif }
It's a part of example source code.
If you look at this source code, you will understand what I mean.
"#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)"
-
So from the looks of it, it's a metadata that cannot be retrieved on these two platforms for some reason like not provided by the platform API.