Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to access Metadata from audio files
Forum Updated to NodeBB v4.3 + New Features

How to access Metadata from audio files

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
20 Posts 2 Posters 6.8k 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.
  • p3c0P Offline
    p3c0P Offline
    p3c0
    Moderators
    wrote on last edited by
    #8

    @Nisha_R Thats strange. Try following:

    import QtQuick 2.6
    import QtMultimedia 5.6
    
    Item {
        width: 400
        height: 400
    
        Text {
             text: "Click Me!";
             font.pointSize: 24;
             width: 150; height: 50;
    
             MediaPlayer {
                 id: playMusic
                 source: "MySong.mp3"
             }
             MouseArea {
                 id: playArea
                 anchors.fill: parent
                 onPressed:  {
                     playMusic.play()
                     console.log(playMusic.metaData.title)
                     console.log(playMusic.metaData.albumTitle)
                     console.log(playMusic.metaData.genre)
                     console.log(playMusic.metaData.year)
                 }
             }
         }
    }
    
    

    157

    1 Reply Last reply
    0
    • Nisha_RN Offline
      Nisha_RN Offline
      Nisha_R
      wrote on last edited by
      #9

      @p3c0 thank you.

      1 Reply Last reply
      1
      • Nisha_RN Offline
        Nisha_RN Offline
        Nisha_R
        wrote on last edited by
        #10

        @p3c0 Thank you again,
        i have got it right when i set the relative path for the mp3 file i,e the source , but when i try to access the mp3 files from resources it is still undefined.

        1 Reply Last reply
        1
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #11

          @Nisha_R How did you set the source ?

          157

          1 Reply Last reply
          1
          • Nisha_RN Offline
            Nisha_RN Offline
            Nisha_R
            wrote on last edited by Nisha_R
            #12

            @p3c0 ,
            i had initially dumped the mp3 files in resources folder and tried to access those in my code.

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #13

              @Nisha_R No. I meant to say the source url. What does it look like? Can you post it ? Checking if the url from resource is correct.

              157

              1 Reply Last reply
              0
              • Nisha_RN Offline
                Nisha_RN Offline
                Nisha_R
                wrote on last edited by Nisha_R
                #14

                @p3c0 this is what i have given.
                Audio {
                id: playMusic
                source: "qrc:/music/2.mp3;"
                }
                music being the folder in resources.

                1 Reply Last reply
                0
                • p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by
                  #15

                  @Nisha_R Why the extra semicolon at the end in source ?
                  Does the Application Output show any errors ?

                  157

                  1 Reply Last reply
                  0
                  • Nisha_RN Offline
                    Nisha_RN Offline
                    Nisha_R
                    wrote on last edited by
                    #16

                    @p3c0 there is no error with respect to the semicolon .
                    setting its path with respect to resources shows undefined, but when its relative path is set the metadata is displayed.

                    1 Reply Last reply
                    1
                    • p3c0P Offline
                      p3c0P Offline
                      p3c0
                      Moderators
                      wrote on last edited by
                      #17

                      @Nisha_R Did you try removing the semicolon ?
                      Also are you sure the file is present at the same location in the resource ?

                      157

                      1 Reply Last reply
                      1
                      • Nisha_RN Offline
                        Nisha_RN Offline
                        Nisha_R
                        wrote on last edited by
                        #18

                        @p3c0
                        yes , i have tried, still undefined.

                        1 Reply Last reply
                        0
                        • p3c0P Offline
                          p3c0P Offline
                          p3c0
                          Moderators
                          wrote on last edited by
                          #19

                          @Nisha_R Does it play from resources ? Can you post a complete minimal example with this Audio element here?

                          157

                          1 Reply Last reply
                          0
                          • Nisha_RN Offline
                            Nisha_RN Offline
                            Nisha_R
                            wrote on last edited by Nisha_R
                            #20

                            @p3c0 okay that will be helpful.

                            MediaPlayer{
                                        id: player;
                                        playlist: Playlist {
                                            id: playlist
                                            PlaylistItem { source: "qrc:/music/4.mp3"}
                                            PlaylistItem { source: "qrc:/music/5.mp3"}
                                        }
                                    }
                             ListView {
                                        model: playlist;
                                        delegate: Text {
                                            font.pixelSize: 16;
                                            text: player.metaData.title+"\n"+player.metaData.albumArtist+"\n"+player.metaData.author;
                                        }
                                    }
                            Rectangle {
                                        id: rectangle2
                                        x: 182
                                        y: 224
                                        width: 78
                                        height: 51
                                        color: "#b35e5e"
                                        MouseArea {
                                            anchors.fill: parent;
                                            onPressed: {
                                                if (player.playbackState != Audio.PlayingState) {
                                                    player.play() }
                                                else {
                                                    player.pause();
                                                         }
                                                                  }
                                                }
                               }
                            
                            1 Reply Last reply
                            1

                            • Login

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