[js] pool for benshee player only if it is installed
fix mpris track change
This commit is contained in:
parent
d2d92e7de3
commit
aa41133f63
|
@ -18,6 +18,7 @@
|
||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
##
|
||||||
|
import os
|
||||||
import gobject
|
import gobject
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# install _() func before importing dbus_support
|
# install _() func before importing dbus_support
|
||||||
|
@ -54,7 +55,7 @@ class MusicTrackListener(gobject.GObject):
|
||||||
## MPRIS
|
## MPRIS
|
||||||
bus.add_signal_receiver(self._mpris_music_track_change_cb, 'TrackChange',
|
bus.add_signal_receiver(self._mpris_music_track_change_cb, 'TrackChange',
|
||||||
'org.freedesktop.MediaPlayer')
|
'org.freedesktop.MediaPlayer')
|
||||||
bus.add_signal_receiver(self._player_playing_changed_cb, 'StatusChange',
|
bus.add_signal_receiver(self._mpris_playing_changed_cb, 'StatusChange',
|
||||||
'org.freedesktop.MediaPlayer')
|
'org.freedesktop.MediaPlayer')
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,6 +78,10 @@ class MusicTrackListener(gobject.GObject):
|
||||||
'playingSongPropertyChanged', 'org.gnome.Rhythmbox.Player')
|
'playingSongPropertyChanged', 'org.gnome.Rhythmbox.Player')
|
||||||
|
|
||||||
## Banshee
|
## Banshee
|
||||||
|
# Banshee sucks because it only supports polling.
|
||||||
|
# Thus, we only register this is we are very sure that it's
|
||||||
|
# installed.
|
||||||
|
if os.name == 'posix' and os.system('which banshee >/dev/null 2>&1') == 0:
|
||||||
banshee_bus = dbus.SessionBus()
|
banshee_bus = dbus.SessionBus()
|
||||||
dubus = banshee_bus.get_object('org.freedesktop.DBus',
|
dubus = banshee_bus.get_object('org.freedesktop.DBus',
|
||||||
'/org/freedesktop/dbus')
|
'/org/freedesktop/dbus')
|
||||||
|
@ -131,6 +136,10 @@ class MusicTrackListener(gobject.GObject):
|
||||||
info.duration = int(song['length'])
|
info.duration = int(song['length'])
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
def _mpris_playing_changed_cb(self, playing):
|
||||||
|
if playing == 2:
|
||||||
|
self.emit('music-track-changed', None)
|
||||||
|
|
||||||
def _mpris_music_track_change_cb(self, arg):
|
def _mpris_music_track_change_cb(self, arg):
|
||||||
info = self._mpris_properties_extract(arg)
|
info = self._mpris_properties_extract(arg)
|
||||||
self.emit('music-track-changed', info)
|
self.emit('music-track-changed', info)
|
||||||
|
|
Loading…
Reference in New Issue