From cdc92409e300e6452266a9fb7eb3f00872f7d411 Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Sat, 6 Oct 2012 23:15:38 +0400 Subject: [PATCH] Mpris2Plugin. correctly pause support. --- mpris2_support/manifest.ini | 2 +- mpris2_support/mpris2_support.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mpris2_support/manifest.ini b/mpris2_support/manifest.ini index 7166e26..1aaa5da 100644 --- a/mpris2_support/manifest.ini +++ b/mpris2_support/manifest.ini @@ -1,7 +1,7 @@ [info] name: MPRIS2 support short_name: mpris2_support -version: 0.1 +version: 0.2 description: MPRIS2 support. Allows to update status message according to the music you're listening via the MPRIS2 D-Bus API. authors = Denis Fomin homepage = http://trac-plugins.gajim.org/wiki/MprisSupportPlugin diff --git a/mpris2_support/mpris2_support.py b/mpris2_support/mpris2_support.py index 72e8d97..4e67147 100644 --- a/mpris2_support/mpris2_support.py +++ b/mpris2_support/mpris2_support.py @@ -23,6 +23,7 @@ class Mpris2Plugin(GajimPlugin): @log_calls('NowListenPlugin') def activate(self): + self._last_playing_music = None self.bus = dbus_support.session_bus.SessionBus() self.bus.add_signal_receiver(self.properties_changed, "PropertiesChanged", "org.freedesktop.DBus.Properties") @@ -39,7 +40,9 @@ class Mpris2Plugin(GajimPlugin): if args[1]['PlaybackStatus'] in ['Paused', 'Stopped']: self.title = self.artist = self.source = '' self.listener.emit('music-track-changed', None) - return + if args[1]['PlaybackStatus'] == 'Playing': + self.listener.emit('music-track-changed', + self._last_playing_music) if 'Metadata' not in args[1]: return @@ -50,4 +53,5 @@ class Mpris2Plugin(GajimPlugin): info.artist = data.get("xesam:artist", [''])[0] info.duration = int(data.get('mpris:length', 0)) info.track_number = int(data.get('xesam:trackNumber', 0)) + self._last_playing_music = info self.listener.emit('music-track-changed', info)