Merge branch '0.9'
This commit is contained in:
commit
c729db4e47
1 changed files with 9 additions and 4 deletions
|
@ -73,7 +73,10 @@ void MprisControlPlugin::addPlayer(const QString& service)
|
||||||
{
|
{
|
||||||
QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");
|
QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");
|
||||||
//FIXME: This call hangs and returns an empty string if KDED is still starting!
|
//FIXME: This call hangs and returns an empty string if KDED is still starting!
|
||||||
const QString identity = mprisInterface.property("Identity").toString();
|
QString identity = mprisInterface.property("Identity").toString();
|
||||||
|
if (identity.isEmpty()) {
|
||||||
|
identity = service.mid(sizeof("org.mpris.MediaPlayer2"));
|
||||||
|
}
|
||||||
playerList[identity] = service;
|
playerList[identity] = service;
|
||||||
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris addPlayer" << service << "->" << identity;
|
qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris addPlayer" << service << "->" << identity;
|
||||||
sendPlayerList();
|
sendPlayerList();
|
||||||
|
@ -178,6 +181,7 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
|
||||||
|
|
||||||
//Do something to the mpris interface
|
//Do something to the mpris interface
|
||||||
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
|
OrgMprisMediaPlayer2PlayerInterface mprisInterface(playerList[player], "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus());
|
||||||
|
mprisInterface.setTimeout(500);
|
||||||
if (np.has("action")) {
|
if (np.has("action")) {
|
||||||
const QString& action = np.get<QString>("action");
|
const QString& action = np.get<QString>("action");
|
||||||
//qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Calling action" << action << "in" << playerList[player];
|
//qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Calling action" << action << "in" << playerList[player];
|
||||||
|
@ -211,15 +215,16 @@ bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
|
||||||
QString nowPlaying = nowPlayingMap["xesam:title"].toString();
|
QString nowPlaying = nowPlayingMap["xesam:title"].toString();
|
||||||
if (nowPlayingMap.contains("xesam:artist")) {
|
if (nowPlayingMap.contains("xesam:artist")) {
|
||||||
nowPlaying = nowPlayingMap["xesam:artist"].toString() + " - " + nowPlaying;
|
nowPlaying = nowPlayingMap["xesam:artist"].toString() + " - " + nowPlaying;
|
||||||
}if (nowPlayingMap.contains("mpris:length")) {
|
}
|
||||||
|
answer.set("nowPlaying",nowPlaying);
|
||||||
|
|
||||||
|
if (nowPlayingMap.contains("mpris:length")) {
|
||||||
qlonglong length = nowPlayingMap["mpris:length"].toLongLong();
|
qlonglong length = nowPlayingMap["mpris:length"].toLongLong();
|
||||||
answer.set("length",length/1000);
|
answer.set("length",length/1000);
|
||||||
}
|
}
|
||||||
qlonglong pos = mprisInterface.position();
|
qlonglong pos = mprisInterface.position();
|
||||||
answer.set("pos", pos/1000);
|
answer.set("pos", pos/1000);
|
||||||
|
|
||||||
answer.set("nowPlaying",nowPlaying);
|
|
||||||
|
|
||||||
bool playing = (mprisInterface.playbackStatus() == QLatin1String("Playing"));
|
bool playing = (mprisInterface.playbackStatus() == QLatin1String("Playing"));
|
||||||
answer.set("isPlaying", playing);
|
answer.set("isPlaying", playing);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue