Skip to content

Commit 7aa58aa

Browse files
author
happyleavesaoc
committed
add Client.SetStream
1 parent 680e37f commit 7aa58aa

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='snapcast',
5-
version='1.0.0',
5+
version='1.1.0',
66
description='Control Snapcast.',
77
url='https://github.com/happyleavesaoc/python-snapcast/',
88
license='MIT',

snapcast/control.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CLIENT_SETNAME = 'Client.SetName'
1919
CLIENT_SETLATENCY = 'Client.SetLatency'
2020
CLIENT_SETMUTE = 'Client.SetMute'
21+
CLIENT_SETSTREAM = 'Client.SetStream'
2122
CLIENT_SETVOLUME = 'Client.SetVolume'
2223
CLIENT_ONUPDATE = 'Client.OnUpdate'
2324
CLIENT_ONDELETE = 'Client.OnDelete'
@@ -27,7 +28,8 @@
2728
_EVENTS = [CLIENT_ONUPDATE, CLIENT_ONCONNECT, CLIENT_ONDISCONNECT,
2829
CLIENT_ONDELETE]
2930
_METHODS = [SERVER_GETSTATUS, SERVER_DELETECLIENT, CLIENT_SETNAME,
30-
CLIENT_SETLATENCY, CLIENT_SETMUTE, CLIENT_SETVOLUME]
31+
CLIENT_SETLATENCY, CLIENT_SETSTREAM, CLIENT_SETMUTE,
32+
CLIENT_SETVOLUME]
3133

3234

3335
class Snapclient:
@@ -58,7 +60,7 @@ def version(self):
5860
@property
5961
def connected(self):
6062
""" Connected or not. """
61-
return self._client.get('version')
63+
return self._client.get('connected')
6264

6365
@property
6466
def name(self):
@@ -94,6 +96,17 @@ def muted(self, status):
9496
self._client['volume']['muted'] = self._server.client_muted(self._mac,
9597
status)
9698

99+
@property
100+
def stream(self):
101+
""" Volume percent. """
102+
return self._client.get('stream')
103+
104+
@stream.setter
105+
def stream(self, path):
106+
""" Set client stream path. """
107+
self._client['stream'] = self._server.client_stream(
108+
self._mac, path)
109+
97110
@property
98111
def volume(self):
99112
""" Volume percent. """
@@ -105,8 +118,7 @@ def volume(self, percent):
105118
if percent not in range(0, 101):
106119
raise ValueError('Volume percent out of range')
107120
self._client['volume']['percent'] = self._server.client_volume(
108-
self._mac,
109-
percent)
121+
self._mac, percent)
110122

111123
def update(self, data):
112124
""" Update client with new state. """
@@ -168,6 +180,10 @@ def client_muted(self, mac, muted):
168180
""" Set client mute status. """
169181
return self._client(CLIENT_SETMUTE, mac, 'mute', muted)
170182

183+
def client_stream(self, mac, stream):
184+
""" Set client stream. """
185+
return self._client(CLIENT_SETSTREAM, mac, 'stream', stream)
186+
171187
def client_volume(self, mac, volume):
172188
""" Set client volume. """
173189
return self._client(CLIENT_SETVOLUME, mac, 'volume', volume)

0 commit comments

Comments
 (0)