-
Notifications
You must be signed in to change notification settings - Fork 43
/
dbusinterface.py
72 lines (55 loc) · 2.42 KB
/
dbusinterface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import dbus
from dbus.service import Object
from dbus.mainloop.glib import DBusGMainLoop
TBOPLAYER_DBUS_OBJECT = "org.tboplayer.TBOPlayer"
TBOPLAYER_DBUS_PATH = "/org/tboplayer/TBOPlayer"
TBOPLAYER_DBUS_INTERFACE = "org.tboplayer.TBOPlayer"
class TBOPlayerDBusInterface (Object):
tboplayer_instance = None
def __init__(self, tboplayer_instance):
self.tboplayer_instance = tboplayer_instance
dbus_loop = DBusGMainLoop(set_as_default=True)
bus_name = dbus.service.BusName(TBOPLAYER_DBUS_OBJECT, bus = dbus.SessionBus(mainloop = dbus_loop))
Object.__init__(self, bus_name, TBOPLAYER_DBUS_PATH)
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE, in_signature = 'as')
def openFiles(self, files):
self.tboplayer_instance._add_files(files)
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE, in_signature='s')
def openPlaylist(self, file):
self.tboplayer_instance._open_list(file)
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE, in_signature='s')
def openUrl(self, url):
self.tboplayer_instance._add_url(url)
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE, in_signature = 'i')
def play(self, track_index=0):
self.tboplayer_instance.play_track_by_index(track_index)
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def pause(self):
self.tboplayer_instance.toggle_pause()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def stop(self):
self.tboplayer_instance.stop_track()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def next(self):
self.tboplayer_instance.skip_to_next_track()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def previous(self):
self.tboplayer_instance.skip_to_previous_track()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def fullscreen(self):
self.tboplayer_instance.toggle_full_screen()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def volumnDown(self):
self.tboplayer_instance.volminus()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def volumnUp(self):
self.tboplayer_instance.volplus()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE)
def clearList(self):
self.tboplayer_instance.clear_list()
@dbus.service.method(TBOPLAYER_DBUS_INTERFACE, in_signature='ss')
def setOption(self, option, value):
try:
self.tboplayer_instance.set_option(option, value)
except Exception, e:
raise e