Commit 90f1694a authored by Michael Pyne's avatar Michael Pyne

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
parent 280ac1e3
......@@ -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(
......
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