1
# -*- coding: utf-8 -*-
3
# This file is part of emesene.
5
# Emesene is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# emesene is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with emesene; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
# based on plugin by Tomer Haimovich
22
IFACE_NAME = 'org.gnome.Listen'
23
IFACE_PATH = '/org/gnome/listen'
28
class Listen( CurrentSong.DbusBase ):
29
'''Communicate with GNOME's Listen player'''
32
CurrentSong.DbusBase.__init__( self, IFACE_NAME, self.setInterface )
35
except: self.iface = None
37
def setInterface( self ):
38
self.iface = self.bus.get_object( IFACE_NAME, IFACE_PATH )
41
if not self.iface or not self.isNameActive(IFACE_NAME):
44
message = self.iface.current_playing()
46
# process the received string. it's built this way:
47
# <m_track> - (<m_album> - <m_artist>)
50
buf = message.split(" - (")
52
secbuf = buf[1].split(" - ")
54
artist = secbuf[1][0:-1]
56
if title != self.title or \
57
album != self.album or \
58
artist != self.artist:
67
if not self.isRunning(): return False
68
if not self.iface: return False
70
self.iface.current_playing()
76
return self.isNameActive(IFACE_NAME)