How to access Metadata from audio files
-
@p3c0 Thank you ,
i have tried with the below code, could you suggest if there are any changes to be made.Window { visible: true width: 640 height: 480 title: qsTr("Hello World") MouseArea { anchors.fill: parent onClicked: { a.play() console.log(a.title) } } MediaPlayer{ id:a source: musicfile path readonly property string title: !!metaData.author && !!metaData.year ? qsTr("%1 - %2").arg(metaData.author).arg(metaData.year): metaData.author && metaData.year && source}
-
@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) } } } }
-
@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(); } } } }