Start playing on add to playlist.
[nephilim.git] / jmpc.py
blob02a7592fb15f3baed8a391e0e009bd447f9a6c64
1 import socket
3 class MPDError(Exception):
4 pass
5 class ConnectionError(MPDError):
6 pass
7 class ProtocolError(MPDError):
8 pass
9 class CommandError(MPDError):
10 pass
11 class CommandListError(MPDError):
12 pass
15 class client:
16 _csock=None
17 _rfile=None
18 _wfile=None
19 def __init__(self):
20 pass
22 def connect(self, host, port, type=socket.SOCK_STREAM):
23 if self._csock:
24 raise ConnectionError("Already connected")
26 self._csock=socket.socket(socket.AF_INET, type)
27 self._csock.connect((host, port))
28 self._file = self._csock.makefile("rwb")
29 handshake=self._read()
30 if handshake[0:len("hello jmpd")]!="hello jmpd":
31 print("Failed to handshake: %s" % (handshake))
32 self.disconnect()
33 return
34 self._write("ack")
37 def _read(self):
38 return self._file.readline().strip()
39 def _write(self, line):
40 self._file.write("%s\n" % (line))
42 def disconnect(self):
43 self._csock.close()
44 self._csock=None
46 def command_list_ok_begin(self):
47 pass
49 def command_list_end(self):
50 pass
52 def update(self):
53 pass
55 def status(self):
56 pass
58 def playid(id):
59 pass
60 def stop(self):
61 pass
63 def pause(self):
64 pass
65 def resume(self):
66 pass
68 def next(self):
69 pass
70 def previous(self):
71 pass
73 def seekid(time):
74 pass
76 # Playlist management
77 def add(path):
78 pass
79 def deleteid(path):
80 pass
82 # volume
83 def setvol(newvolume):
84 pass
86 # info
87 def listallinfo(self):
88 pass
89 def listplaylistinfo(self):
90 pass
91 def currentsong(self):
92 pass
95 from test import port
96 client=client()
97 client.connect('localhost', port)
98 client.disconnect()