aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/mpris
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/General/mpris')
-rw-r--r--src/plugins/General/mpris/mpris1/playerobject.cpp37
-rw-r--r--src/plugins/General/mpris/mpris1/tracklistobject.cpp12
-rw-r--r--src/plugins/General/mpris/mpris2/player2object.cpp59
3 files changed, 55 insertions, 53 deletions
diff --git a/src/plugins/General/mpris/mpris1/playerobject.cpp b/src/plugins/General/mpris/mpris1/playerobject.cpp
index a1b3c490b..77ea85d2a 100644
--- a/src/plugins/General/mpris/mpris1/playerobject.cpp
+++ b/src/plugins/General/mpris/mpris1/playerobject.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2017 by Ilya Kotov *
+ * Copyright (C) 2008-2018 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -61,7 +61,7 @@ PlayerObject::PlayerObject(QObject *parent) : QObject(parent)
m_pl_manager = m_player->playListManager();
m_ui_settings = QmmpUiSettings::instance();
connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(updateCaps()));
- connect(m_core, SIGNAL(metaDataChanged ()), SLOT(updateTrack()));
+ connect(m_core, SIGNAL(trackInfoChanged()), SLOT(updateTrack()));
connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(updateStatus()));
connect(m_ui_settings, SIGNAL(repeatableListChanged(bool)), SLOT(updateStatus()));
connect(m_ui_settings, SIGNAL(shuffleChanged(bool)), SLOT(updateStatus()));
@@ -126,25 +126,26 @@ PlayerStatus PlayerObject::GetStatus()
QVariantMap PlayerObject::GetMetadata()
{
+ TrackInfo info = m_core->trackInfo();
QVariantMap map;
- if (m_core->metaData(Qmmp::URL).contains("://"))
- map.insert("location", m_core->metaData(Qmmp::URL));
+ if (info.path().contains("://"))
+ map.insert("location", info.path());
else
- map.insert("location", "file://" + m_core->metaData(Qmmp::URL));
- map.insert("arturl", MetaDataManager::instance()->getCoverPath(m_core->metaData(Qmmp::URL)));
- map.insert("title", m_core->metaData(Qmmp::TITLE));
- map.insert("artist", m_core->metaData(Qmmp::ARTIST));
- map.insert("albumartist", m_core->metaData(Qmmp::ALBUMARTIST));
- map.insert("album", m_core->metaData(Qmmp::ALBUM));
- map.insert("tracknumber", m_core->metaData(Qmmp::TRACK));
- map.insert("time", (quint32)m_core->duration()/1000);
- map.insert("mtime", (quint32)m_core->duration());
- map.insert("genre", m_core->metaData(Qmmp::GENRE));
- map.insert("comment", m_core->metaData(Qmmp::COMMENT));
- map.insert("audio-bitrate", (quint32)m_core->bitrate());
- map.insert("audio-samplerate", (quint32)m_core->audioParameters().sampleRate());
- map.insert("year", m_core->metaData(Qmmp::YEAR).toUInt());
+ map.insert("location", "file://" + info.path());
+ map.insert("arturl", MetaDataManager::instance()->getCoverPath(info.path()));
+ map.insert("title", info.value(Qmmp::TITLE));
+ map.insert("artist", info.value(Qmmp::ARTIST));
+ map.insert("albumartist", info.value(Qmmp::ALBUMARTIST));
+ map.insert("album", info.value(Qmmp::ALBUM));
+ map.insert("tracknumber", info.value(Qmmp::TRACK));
+ map.insert("time", (quint32)info.duration()/1000);
+ map.insert("mtime", (quint32)info.duration());
+ map.insert("genre", info.value(Qmmp::GENRE));
+ map.insert("comment", info.value(Qmmp::COMMENT));
+ map.insert("audio-bitrate", (quint32)info.value(Qmmp::BITRATE).toInt());
+ map.insert("audio-samplerate", (quint32)info.value(Qmmp::SAMPLERATE).toInt());
+ map.insert("year", info.value(Qmmp::YEAR).toUInt());
return map;
}
diff --git a/src/plugins/General/mpris/mpris1/tracklistobject.cpp b/src/plugins/General/mpris/mpris1/tracklistobject.cpp
index 740339c11..64b03bc51 100644
--- a/src/plugins/General/mpris/mpris1/tracklistobject.cpp
+++ b/src/plugins/General/mpris/mpris1/tracklistobject.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2015 by Ilya Kotov *
+ * Copyright (C) 2008-2018 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -84,17 +84,17 @@ QVariantMap TrackListObject::GetMetadata(int in0)
if (track)
{
- if (track->url().contains("://"))
- map.insert("location", track->url());
+ if (track->path().contains("://"))
+ map.insert("location", track->path());
else
- map.insert("location", "file://" + track->url());
+ map.insert("location", "file://" + track->path());
map.insert("title", track->value(Qmmp::TITLE));
map.insert("artist", track->value(Qmmp::ARTIST));
map.insert("albumartist", track->value(Qmmp::ALBUMARTIST));
map.insert("album", track->value(Qmmp::ALBUM));
map.insert("tracknumber", track->value(Qmmp::TRACK));
- map.insert("time", (quint32)track->length());
- map.insert("mtime", (quint32)track->length() * 1000);
+ map.insert("time", (quint32)track->duration() / 1000);
+ map.insert("mtime", (quint32)track->duration());
map.insert("genre", track->value(Qmmp::GENRE));
map.insert("comment", track->value(Qmmp::COMMENT));
map.insert("year", track->value(Qmmp::YEAR).toUInt());
diff --git a/src/plugins/General/mpris/mpris2/player2object.cpp b/src/plugins/General/mpris/mpris2/player2object.cpp
index cee1aebfe..962d8a618 100644
--- a/src/plugins/General/mpris/mpris2/player2object.cpp
+++ b/src/plugins/General/mpris/mpris2/player2object.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2017 by Ilya Kotov *
+ * Copyright (C) 2010-2018 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -38,8 +38,8 @@ Player2Object::Player2Object(QObject *parent) : QDBusAbstractAdaptor(parent)
m_player = MediaPlayer::instance();
m_pl_manager = m_player->playListManager();
m_ui_settings = QmmpUiSettings::instance();
- connect(m_core, SIGNAL(metaDataChanged ()), SLOT(updateId()));
- connect(m_core, SIGNAL(metaDataChanged ()), SLOT(emitPropertiesChanged()));
+ connect(m_core, SIGNAL(trackInfoChanged()), SLOT(updateId()));
+ connect(m_core, SIGNAL(trackInfoChanged()), SLOT(emitPropertiesChanged()));
connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(checkState(Qmmp::State)));
connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(emitPropertiesChanged()));
connect(m_core, SIGNAL(volumeChanged(int,int)), SLOT(emitPropertiesChanged()));
@@ -123,40 +123,41 @@ double Player2Object::maximumRate() const
QVariantMap Player2Object::metadata() const
{
PlayListTrack *track = m_pl_manager->currentPlayList()->currentTrack();
- if(!track || m_core->metaData(Qmmp::URL).isEmpty())
+ if(!track || m_core->path().isEmpty())
return QVariantMap();
QVariantMap map;
+ TrackInfo info = m_core->trackInfo();
map["mpris:length"] = qMax(m_core->duration() * 1000 , qint64(0));
- if(!MetaDataManager::instance()->getCoverPath(m_core->metaData(Qmmp::URL)).isEmpty())
+ if(!MetaDataManager::instance()->getCoverPath(info.path()).isEmpty())
{
map["mpris:artUrl"] = QUrl::fromLocalFile(
- MetaDataManager::instance()->getCoverPath(m_core->metaData(Qmmp::URL))).toString();
+ MetaDataManager::instance()->getCoverPath(info.path())).toString();
}
- if(!m_core->metaData(Qmmp::ALBUM).isEmpty())
- map["xesam:album"] = m_core->metaData(Qmmp::ALBUM);
- if(!m_core->metaData(Qmmp::ARTIST).isEmpty())
- map["xesam:artist"] = QStringList() << m_core->metaData(Qmmp::ARTIST);
- if(!m_core->metaData(Qmmp::ALBUMARTIST).isEmpty())
- map["xesam:albumArtist"] = QStringList() << m_core->metaData(Qmmp::ALBUMARTIST);
- if(!m_core->metaData(Qmmp::COMMENT).isEmpty())
- map["xesam:comment"] = QStringList() << m_core->metaData(Qmmp::COMMENT);
- if(!m_core->metaData(Qmmp::COMPOSER).isEmpty())
- map["xesam:composer"] = QStringList() << m_core->metaData(Qmmp::COMPOSER);
- if(!m_core->metaData(Qmmp::DISCNUMBER).isEmpty())
- map["xesam:discNumber"] = m_core->metaData(Qmmp::DISCNUMBER).toInt();
- if(!m_core->metaData(Qmmp::GENRE).isEmpty())
- map["xesam:genre"] = QStringList() << m_core->metaData(Qmmp::GENRE);
- if(!m_core->metaData(Qmmp::TITLE).isEmpty())
- map["xesam:title"] = m_core->metaData(Qmmp::TITLE);
- if(!m_core->metaData(Qmmp::TRACK).isEmpty())
- map["xesam:trackNumber"] = m_core->metaData(Qmmp::TRACK).toInt();
- if(!m_core->metaData(Qmmp::YEAR).isEmpty())
- map["xesam:contentCreated"] = m_core->metaData(Qmmp::YEAR);
+ if(!info.value(Qmmp::ALBUM).isEmpty())
+ map["xesam:album"] = info.value(Qmmp::ALBUM);
+ if(!info.value(Qmmp::ARTIST).isEmpty())
+ map["xesam:artist"] = QStringList() << info.value(Qmmp::ARTIST);
+ if(!info.value(Qmmp::ALBUMARTIST).isEmpty())
+ map["xesam:albumArtist"] = QStringList() << info.value(Qmmp::ALBUMARTIST);
+ if(!info.value(Qmmp::COMMENT).isEmpty())
+ map["xesam:comment"] = QStringList() << info.value(Qmmp::COMMENT);
+ if(!info.value(Qmmp::COMPOSER).isEmpty())
+ map["xesam:composer"] = QStringList() << info.value(Qmmp::COMPOSER);
+ if(!info.value(Qmmp::DISCNUMBER).isEmpty())
+ map["xesam:discNumber"] = info.value(Qmmp::DISCNUMBER).toInt();
+ if(!info.value(Qmmp::GENRE).isEmpty())
+ map["xesam:genre"] = QStringList() << info.value(Qmmp::GENRE);
+ if(!info.value(Qmmp::TITLE).isEmpty())
+ map["xesam:title"] = info.value(Qmmp::TITLE);
+ if(!info.value(Qmmp::TRACK).isEmpty())
+ map["xesam:trackNumber"] = info.value(Qmmp::TRACK).toInt();
+ if(!info.value(Qmmp::YEAR).isEmpty())
+ map["xesam:contentCreated"] = info.value(Qmmp::YEAR);
map["mpris:trackid"] = QVariant::fromValue<QDBusObjectPath>(m_trackID);
- if(m_core->metaData(Qmmp::URL).startsWith("/"))
- map["xesam:url"] = QUrl::fromLocalFile(m_core->metaData(Qmmp::URL)).toString();
+ if(info.path().startsWith("/"))
+ map["xesam:url"] = QUrl::fromLocalFile(info.path()).toString();
else
- map["xesam:url"] = m_core->metaData(Qmmp::URL);
+ map["xesam:url"] = info.path();
return map;
}