aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pyne <[email protected]>2017-10-06 22:31:07 -0400
committerMichael Pyne <[email protected]>2017-10-06 22:31:07 -0400
commit90f1694a3efc631871545e05b1f3343849f067fc (patch)
tree415d6d53577cb4e550a5e84bdbf2f02f5b7f3fd7
parent280ac1e377ea42dbe85e8151ddb0a4f126f54df6 (diff)
mpris2: Do not set MPRIS2 metadata for empty fields.
Based on the patch submitted nearly 3 years ago by James Smith. :( This matches the behavior of many other media players supporting MPRIS2. REVIEW:121731 FIXED-IN:17.12
-rw-r--r--mpris2/mediaplayer2player.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/mpris2/mediaplayer2player.cpp b/mpris2/mediaplayer2player.cpp
index fca9b7f..c7c8738 100644
--- a/mpris2/mediaplayer2player.cpp
+++ b/mpris2/mediaplayer2player.cpp
@@ -188,7 +188,7 @@ QVariantMap MediaPlayer2Player::Metadata() const
// path, and the regex for that is, and I quote: [a-zA-Z0-9_]*, along with
// the normal / delimiters for paths.
PlaylistItem *item = Playlist::playingItem();
- if (!item)
+ if(!item)
return metaData;
FileHandle playingFile = item->file();
@@ -198,10 +198,19 @@ QVariantMap MediaPlayer2Player::Metadata() const
QVariant::fromValue<QDBusObjectPath>(
QDBusObjectPath(playingTrackFileId.constData()));
- metaData["xesam:album"] = playingFile.tag()->album();
- metaData["xesam:title"] = playingFile.tag()->title();
- metaData["xesam:artist"] = QStringList(playingFile.tag()->artist());
- metaData["xesam:genre"] = QStringList(playingFile.tag()->genre());
+ const Tag *tag = playingFile.tag();
+ auto strValue = tag->album();
+ if(!strValue.isEmpty())
+ metaData["xesam:album"] = strValue;
+ strValue = tag->title();
+ if(!strValue.isEmpty())
+ metaData["xesam:title"] = strValue;
+ strValue = tag->artist();
+ if(!strValue.isEmpty())
+ metaData["xesam:artist"] = QStringList(strValue);
+ strValue = tag->genre();
+ if(!strValue.isEmpty())
+ metaData["xesam:genre"] = QStringList(strValue);
metaData["mpris:length"] = qint64(playingFile.tag()->seconds() * 1000000);
metaData["xesam:url"] = QString::fromUtf8(