Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best way to get Media MetaData?
Forum Updated to NodeBB v4.3 + New Features

Best way to get Media MetaData?

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 2.0k Views 2 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.
  • N Offline
    N Offline
    NguyenMinh
    wrote on last edited by NguyenMinh
    #1

    hello,
    In my mp3 player app's add song function, I want to read mp3 files from url and save their title, url, album, artist to a model and display it to view.
    I have tried using another QMediaPlayer in this funtion to read meta data but it too slow (mediaStatus alway LoadingMedia not LoadedMedia).
    Is there any other way to read meta data from file url?

    Pablo J. RoginaP jsulmJ 2 Replies Last reply
    0
    • N NguyenMinh

      hello,
      In my mp3 player app's add song function, I want to read mp3 files from url and save their title, url, album, artist to a model and display it to view.
      I have tried using another QMediaPlayer in this funtion to read meta data but it too slow (mediaStatus alway LoadingMedia not LoadedMedia).
      Is there any other way to read meta data from file url?

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @NguyenMinh have you tried some external library, like TagLib or id3lib?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      N 1 Reply Last reply
      0
      • Pablo J. RoginaP Pablo J. Rogina

        @NguyenMinh have you tried some external library, like TagLib or id3lib?

        N Offline
        N Offline
        NguyenMinh
        wrote on last edited by
        #3

        @Pablo-J.-Rogina This project is actually a homework so I can't use external library

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

          Hi,

          What exactly are you allowed to use ?

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

          N 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            What exactly are you allowed to use ?

            N Offline
            N Offline
            NguyenMinh
            wrote on last edited by
            #5

            @SGaist everything in QT, the point is I have to understand how to do it so external library is not allowed

            1 Reply Last reply
            0
            • N NguyenMinh

              hello,
              In my mp3 player app's add song function, I want to read mp3 files from url and save their title, url, album, artist to a model and display it to view.
              I have tried using another QMediaPlayer in this funtion to read meta data but it too slow (mediaStatus alway LoadingMedia not LoadedMedia).
              Is there any other way to read meta data from file url?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @NguyenMinh said in Best way to get Media MetaData?:

              QMediaPlayer in this funtion to read meta data but it too slow

              Can you show how you're using it?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 1 Reply Last reply
              0
              • jsulmJ jsulm

                @NguyenMinh said in Best way to get Media MetaData?:

                QMediaPlayer in this funtion to read meta data but it too slow

                Can you show how you're using it?

                N Offline
                N Offline
                NguyenMinh
                wrote on last edited by
                #7

                @jsulm I want to do it in a function so I try something like this:

                void addSong(){
                    QMediaPlayer *player=new QMediaPlayer;
                    player->setMedia(QUrl("C:/Users/Public/Music/Sample Music/music1.mp3"));
                    QStringList metadatalist = player->availableMetaData();
                    qDebug()<<metadatalist;
                {
                

                This will fail because setMedia take time to load the file so metadatalist will be a blank string.

                jsulmJ 1 Reply Last reply
                0
                • N NguyenMinh

                  @jsulm I want to do it in a function so I try something like this:

                  void addSong(){
                      QMediaPlayer *player=new QMediaPlayer;
                      player->setMedia(QUrl("C:/Users/Public/Music/Sample Music/music1.mp3"));
                      QStringList metadatalist = player->availableMetaData();
                      qDebug()<<metadatalist;
                  {
                  

                  This will fail because setMedia take time to load the file so metadatalist will be a blank string.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @NguyenMinh Yes you can't do it like this. Qt is assynchronous.
                  Actually, you can use https://doc.qt.io/qt-5/qmediaobject.html
                  Connect a slot to https://doc.qt.io/qt-5/qmediaobject.html#availabilityChanged signal and read meta data there if parameter is true.
                  Maybe https://doc.qt.io/qt-5/qmediaobject.html#metaDataChanged is of interest as well.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @NguyenMinh Yes you can't do it like this. Qt is assynchronous.
                    Actually, you can use https://doc.qt.io/qt-5/qmediaobject.html
                    Connect a slot to https://doc.qt.io/qt-5/qmediaobject.html#availabilityChanged signal and read meta data there if parameter is true.
                    Maybe https://doc.qt.io/qt-5/qmediaobject.html#metaDataChanged is of interest as well.

                    N Offline
                    N Offline
                    NguyenMinh
                    wrote on last edited by
                    #9

                    @jsulm thank you, I understand your solution but i have 1 more question:
                    Is it possible to using QMediaObject class or we have to use its subclass like QMediaPlayer? Is there any "cheaper" way?

                    jsulmJ 1 Reply Last reply
                    0
                    • N NguyenMinh

                      @jsulm thank you, I understand your solution but i have 1 more question:
                      Is it possible to using QMediaObject class or we have to use its subclass like QMediaPlayer? Is there any "cheaper" way?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @NguyenMinh You can use QMediaObject directly as I suggested - should be cheap enough :-)

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      N 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @NguyenMinh You can use QMediaObject directly as I suggested - should be cheap enough :-)

                        N Offline
                        N Offline
                        NguyenMinh
                        wrote on last edited by
                        #11

                        @jsulm but how? the QMediaObject's constructer is protected. And there's no function to set media content.

                        jsulmJ 1 Reply Last reply
                        1
                        • N NguyenMinh

                          @jsulm but how? the QMediaObject's constructer is protected. And there's no function to set media content.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @NguyenMinh You're right. Looks like you have to use QMediaPlayer.

                          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