Mpris2Plugin. correctly pause support.

This commit is contained in:
Denis Fomin
2012-10-06 23:15:38 +04:00
parent 3920e11738
commit cdc92409e3
2 changed files with 6 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
[info] [info]
name: MPRIS2 support name: MPRIS2 support
short_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. description: MPRIS2 support. Allows to update status message according to the music you're listening via the MPRIS2 D-Bus API.
authors = Denis Fomin <fominde@gmail.com> authors = Denis Fomin <fominde@gmail.com>
homepage = http://trac-plugins.gajim.org/wiki/MprisSupportPlugin homepage = http://trac-plugins.gajim.org/wiki/MprisSupportPlugin

View File

@@ -23,6 +23,7 @@ class Mpris2Plugin(GajimPlugin):
@log_calls('NowListenPlugin') @log_calls('NowListenPlugin')
def activate(self): def activate(self):
self._last_playing_music = None
self.bus = dbus_support.session_bus.SessionBus() self.bus = dbus_support.session_bus.SessionBus()
self.bus.add_signal_receiver(self.properties_changed, self.bus.add_signal_receiver(self.properties_changed,
"PropertiesChanged", "org.freedesktop.DBus.Properties") "PropertiesChanged", "org.freedesktop.DBus.Properties")
@@ -39,7 +40,9 @@ class Mpris2Plugin(GajimPlugin):
if args[1]['PlaybackStatus'] in ['Paused', 'Stopped']: if args[1]['PlaybackStatus'] in ['Paused', 'Stopped']:
self.title = self.artist = self.source = '' self.title = self.artist = self.source = ''
self.listener.emit('music-track-changed', None) 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]: if 'Metadata' not in args[1]:
return return
@@ -50,4 +53,5 @@ class Mpris2Plugin(GajimPlugin):
info.artist = data.get("xesam:artist", [''])[0] info.artist = data.get("xesam:artist", [''])[0]
info.duration = int(data.get('mpris:length', 0)) info.duration = int(data.get('mpris:length', 0))
info.track_number = int(data.get('xesam:trackNumber', 0)) info.track_number = int(data.get('xesam:trackNumber', 0))
self._last_playing_music = info
self.listener.emit('music-track-changed', info) self.listener.emit('music-track-changed', info)