-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpdclient.py
39 lines (32 loc) · 862 Bytes
/
mpdclient.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
from mpd import MPDClient
class mpdclient(object):
def __init__(self, host="localhost", port=6600):
self.client = MPDClient()
self.timeout = 10
self.idletimeout = None
self.client.connect(host, port)
self.client.clear()
print "MPD version %s" % self.client.mpd_version
print "mpdclient -> constructor done"
def __del__(self):
if self.client != None:
self.client.stop()
self.client.clear()
self.client.close()
self.client.disconnect()
print "mpdclient -> destructor"
def update(self):
if self.client != None:
self.client.update()
def add(self, uri):
if self.client != None:
self.client.stop()
self.client.clear()
self.client.add(uri)
self.client.play()
def random(self, state):
if self.client != None:
self.client.random(state)
def pause(self):
if self.client != None:
self.client.pause()