How to access Metadata from audio files
Unsolved
QML and Qt Quick
-
-
-
@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) } } } }
-
@Nisha_R How did you set the source ?
-
@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.
-
@Nisha_R Why the extra semicolon at the end in
source
?
Does the Application Output show any errors ? -
@Nisha_R Did you try removing the semicolon ?
Also are you sure the file is present at the same location in the resource ? -
@Nisha_R Does it play from resources ? Can you post a complete minimal example with this
Audio
element here? -
wrote on 3 Jan 2017, 10:18 last edited by Nisha_R 1 Mar 2017, 12:00
@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(); } } } }
13/20