QML 媒体播放器不显示 mp3 流的元数据
QML mediaplayer does not show metaData for mp3 streams
给定以下代码:
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));
}
}
}
我试过的音频流都可以正常播放。但是我无法检索流的元数据。例如。标题、艺术家等。所有元字段都将只是“未定义”。
我试过几个流,none 会显示任何元数据。但我确信流会提供这些信息,因为其他播放器应用程序会显示标题、艺术家等。
我尝试了其他方法(如 here),但我仍然没有得到任何元数据。
我正在 ubuntu 触摸,如果这很重要,应用装甲策略是 ["audio", "networking"]
(也尝试过 music_files_read
,但没有帮助)。
谁能帮帮我?
你忘记了一些小事:
1.audioRole: MediaPlayer.MusicRole
2. mainPage.getMetaData(audioPlayer.metaData));
你应该调用mainPage id然后调用它的函数
这里是正确的代码:
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));
}
}
}
这是输出:
正如您在这张图片中看到的那样 genre: Pop
我测试了来自 this site 的另一首音乐并打印了另一个元数据,未定义意味着源没有此元数据。
给定以下代码:
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));
}
}
}
我试过的音频流都可以正常播放。但是我无法检索流的元数据。例如。标题、艺术家等。所有元字段都将只是“未定义”。
我试过几个流,none 会显示任何元数据。但我确信流会提供这些信息,因为其他播放器应用程序会显示标题、艺术家等。
我尝试了其他方法(如 here),但我仍然没有得到任何元数据。
我正在 ubuntu 触摸,如果这很重要,应用装甲策略是 ["audio", "networking"]
(也尝试过 music_files_read
,但没有帮助)。
谁能帮帮我?
你忘记了一些小事:
1.audioRole: MediaPlayer.MusicRole
2. mainPage.getMetaData(audioPlayer.metaData));
你应该调用mainPage id然后调用它的函数
这里是正确的代码:
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));
}
}
}
这是输出:
正如您在这张图片中看到的那样 genre: Pop
我测试了来自 this site 的另一首音乐并打印了另一个元数据,未定义意味着源没有此元数据。