| Home | Trees | Indices | Help |
|
|---|
|
|
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13
14
15 # Listen API by vrunner
16
17 import os
18 import dbus
19 import string
20 import gobject
21 from GenericPlayer import GenericAPI
22
23 #LISTEN = {'DBUS_NAME':'org.gnome.Listen','DBUS_OBJECT':'/org/gnome/listen', \
24 # 'DBUS_TITLE':'get_title()','DBUS_ALBUM':'get_album()', \
25 # 'DBUS_ARTIST':'get_artist()','DBUS_ART':'get_cover_path()',\
26 # 'DBUS_PLAYING':'playing()','PLAY_WORD':False}
27
29 __name__ = 'Listen API'
30 __version__ = '0.0'
31 __author__ = 'vrunner'
32 __desc__ = 'API to the Listen Music Player'
33
34 ns = "org.gnome.Listen"
35 iroot = "/org/gnome/listen"
36 iface = "org.gnome.Listen"
37
38 playerAPI = None
39
40 __timeout = None
41 __interval = 2
42
43 callbackFn = None
44 __curplaying = None
45
46 # Extended Functions from the GenericAPI
47
50
54
56 proxy_obj = self.session_bus.get_object(self.ns, self.iroot)
57 self.playerAPI = dbus.Interface(proxy_obj, self.iface)
58
60 return self.playerAPI.current_playing().split(" - ",3)[0]
61 #return self.playerAPI.get_title()
62
64 return self.playerAPI.current_playing().split(" - ",3)[1][1:]
65 #return self.playerAPI.get_album()
66
70 #return self.playerAPI.get_artist()
71
75 #return self.playerAPI.get_cover_path()
76
78 #if self.playerAPI.playing() == "False": return False
79 if self.playerAPI.current_playing() == "": return False
80 else: return True
81
84
87
90
92 self.callback_fn = fn
93 # Could not find a callback signal for Listen, so just calling after some time interval
94 if self.__timeout:
95 gobject.source_remove(self.__timeout)
96 self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)
97 #self.playerAPI.connect_to_signal("playingUriChanged", self.info_changed)
98
100 # Only call the callback function if Data has changed
101 if self.__timeout:
102 gobject.source_remove(self.__timeout)
103 try:
104 if self.__curplaying != self.playerAPI.current_playing():
105 self.__curplaying = self.playerAPI.current_playing()
106 self.callback_fn()
107
108 self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)
109 except:
110 # The player exited ? call callback function
111 self.callback_fn()
112
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Jan 4 16:58:25 2012 | http://epydoc.sourceforge.net |