Reputation: 3206
Given the following code:
Item {
id: mainPage
anchors.fill: parent
function getMetaData(metaData) {
var text = ""
text += "title: " + metaData.title + "\n"
text += "subTitle: " + metaData.subTitle + "\n"
text += "author: " + metaData.author + "\n"
text += "comment: " + metaData.comment + "\n"
text += "description: " + metaData.description + "\n"
text += "category: " + metaData.category + "\n"
text += "genre: " + metaData.genre + "\n"
text += "language: " + metaData.language + "\n"
text += "albumTitle: " + metaData.albumTitle + "\n"
text += "albumArtist: " + metaData.albumArtist + "\n"
text += "coverArtUrlSmall: " + metaData.coverArtUrlSmall + "\n"
text += "coverArtUrlLarge: " + metaData.coverArtUrlLarge + "\n"
text += "posterUrl: " + metaData.posterUrl + "\n"
return text
}
MediaPlayer {
id: audioPlayer
audioRole: MusicRole
source: "https://s3-webradio.antenne.de/antenne/stream/mp3?aw_0_1st.playerid=radio.de"
//source: "https://swr-swr3-live.cast.addradio.de/swr/swr3/live/mp3/128/stream.mp3"
//source: "http://bob.hoerradar.de/radiobob-hartesaite-mp3-hq?sABC=5r65511s%230%23os634o21s23sr4751opp80560p2o2sr6%23fgernzf.enqvbobo.qr&amsparams=playerid:streams.radiobob.de;skey:1583698207"
onPlaybackStateChanged: {
console.log("State: " + audioPlayer.status + " Meta data: \n" + getMetaData(audioPlayer.metaData));
}
}
}
The audio streams I have tried will playback just fine. However I am unable to retrieve meta data for the streams. E.g. title, artist, and so on. All of the meta fields will just be "undefined".
I have tried several streams, none would show any meta data. Yet I am sure the stream provides those infos, since other player applications will show title, artist, etc.
I have tried other approaches (like here), but still I don't get any metadata.
I am on ubuntu touch, if that matters, and app armor policies are ["audio", "networking"]
(also tried music_files_read
, didn't help).
Can anyone help me out?
Upvotes: 0
Views: 645
Reputation: 3883
you forget some little things:
1.audioRole: MediaPlayer.MusicRole
2. mainPage.getMetaData(audioPlayer.metaData));
you should call mainPage id and then call its function.
here is correct code :
Item {
id: mainPage
anchors.fill: parent
function getMetaData(metaData) {
var text = ""
text += "title: " + metaData.title + "\n"
text += "subTitle: " + metaData.subTitle + "\n"
text += "author: " + metaData.author + "\n"
text += "comment: " + metaData.comment + "\n"
text += "description: " + metaData.description + "\n"
text += "category: " + metaData.category + "\n"
text += "genre: " + metaData.genre + "\n"
text += "language: " + metaData.language + "\n"
text += "albumTitle: " + metaData.albumTitle + "\n"
text += "albumArtist: " + metaData.albumArtist + "\n"
text += "coverArtUrlSmall: " + metaData.coverArtUrlSmall + "\n"
text += "coverArtUrlLarge: " + metaData.coverArtUrlLarge + "\n"
text += "posterUrl: " + metaData.posterUrl + "\n"
return text
}
MediaPlayer {
id: audioPlayer
audioRole: MediaPlayer.MusicRole
source: "https://s3-webradio.antenne.de/antenne/stream/mp3?aw_0_1st.playerid=radio.de"
//source: "https://swr-swr3-live.cast.addradio.de/swr/swr3/live/mp3/128/stream.mp3"
//source: "http://bob.hoerradar.de/radiobob-hartesaite-mp3-hq?sABC=5r65511s%230%23os634o21s23sr4751opp80560p2o2sr6%23fgernzf.enqvbobo.qr&amsparams=playerid:streams.radiobob.de;skey:1583698207"
metaData.onMetaDataChanged: {
console.log("State: " + audioPlayer.status + " Meta data: \n" + mainPage.getMetaData(audioPlayer.metaData));
}
}
}
here is out put :
As you see in this picture it shows genre: Pop
I test another music from this site and print another metadata , undefined means that the source doesn't have this metaData .
Upvotes: 1