Commit 811ae0dd authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Use player "poster" as album cover if available

Media Sessions artwork takes precedence, if set.

Differential Revision: https://phabricator.kde.org/D29393
parent 64a63f2b
......@@ -343,6 +343,7 @@ function setPlayerActive(player) {
sendMessage("mpris", "playing", {
mediaSrc: player.currentSrc || player.src,
pageTitle: document.title,
poster: player.poster,
duration: player.duration,
currentTime: player.currentTime,
playbackRate: player.playbackRate,
......
......@@ -170,6 +170,12 @@ void MPrisPlugin::handleData(const QString &event, const QJsonObject &data)
m_url = QUrl(data.value(QStringLiteral("url")).toString());
m_mediaSrc = QUrl(data.value(QStringLiteral("mediaSrc")).toString());
const QUrl posterUrl = QUrl(data.value(QStringLiteral("poster")).toString());
if (m_posterUrl != posterUrl) {
m_posterUrl = posterUrl;
emitPropertyChange(m_player, "Metadata");
}
const qreal oldVolume = volume();
m_volume = data.value(QStringLiteral("volume")).toDouble(1);
......@@ -451,8 +457,13 @@ QVariantMap MPrisPlugin::metadata() const
if (!m_artist.isEmpty()) {
metadata.insert(QStringLiteral("xesam:artist"), m_artist);
}
if (m_artworkUrl.isValid()) {
metadata.insert(QStringLiteral("mpris:artUrl"), m_artworkUrl.toDisplayString());
QUrl artUrl = m_artworkUrl;
if (!artUrl.isValid()) {
artUrl = m_posterUrl;
}
if (artUrl.isValid()) {
metadata.insert(QStringLiteral("mpris:artUrl"), artUrl.toDisplayString());
}
if (!m_album.isEmpty()) {
......
......@@ -176,6 +176,7 @@ private:
QString m_title;
QString m_artist;
QString m_album;
QUrl m_posterUrl;
QUrl m_artworkUrl;
qreal m_volume = 1.0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment