Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. I want to get album art image from mp3 files

I want to get album art image from mp3 files

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
15 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Hi,

    Why start a new thread when there was already that one ?

    That said, are you sure you are not doing that too early ? i.e. before the file has been loaded ?

    R Offline
    R Offline
    rhaps20
    wrote on last edited by rhaps20
    #3

    @SGaist said in I want to get album art image from mp3 files:

    Hi,
    Why start a new thread when there was already that one ?
    That said, are you sure you are not doing that too early ? i.e. before the file has been loaded ?

    I didn't start new thread.

    when metadata is changed, the function containing the above code is executed.

    1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Why start a new thread when there was already that one ?

      That said, are you sure you are not doing that too early ? i.e. before the file has been loaded ?

      R Offline
      R Offline
      rhaps20
      wrote on last edited by rhaps20
      #4

      @SGaist said in I want to get album art image from mp3 files:

      Hi,
      Why start a new thread when there was already that one ?
      That said, are you sure you are not doing that too early ? i.e. before the file has been loaded ?

      I succeeded the load the title, artist, album title.

      but, I can't load the album image...

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        Does the documentation example show it properly ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        R 1 Reply Last reply
        0
        • SGaistS SGaist

          Does the documentation example show it properly ?

          R Offline
          R Offline
          rhaps20
          wrote on last edited by
          #6

          @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...
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 2 Replies Last reply
            1
            • SGaistS SGaist

              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.

              R Offline
              R Offline
              rhaps20
              wrote on last edited by
              #8
              This post is deleted!
              1 Reply Last reply
              0
              • R Offline
                R Offline
                rhaps20
                wrote on last edited by
                #9

                I tried build my project to Desktop version. It also didn't show cover image.

                1 Reply Last reply
                0
                • SGaistS SGaist

                  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.

                  R Offline
                  R Offline
                  rhaps20
                  wrote on last edited by
                  #10

                  @SGaist
                  Example project show image well.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    So compare your code with the example to find the difference that makes yours fail.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    R 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      So compare your code with the example to find the difference that makes yours fail.

                      R Offline
                      R Offline
                      rhaps20
                      wrote on last edited by
                      #12

                      @SGaist
                      It seems to be a limited situation only when built with the PC version. I think its impossible on android version.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        I am not sure to follow you. It works on your desktop but not on Android ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        R 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          I am not sure to follow you. It works on your desktop but not on Android ?

                          R Offline
                          R Offline
                          rhaps20
                          wrote on last edited by rhaps20
                          #14

                          @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)"

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            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.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved