Control Snapcast.
Project description
python-snapcast
Control Snapcast in Python 3. Reads client configurations, updates clients, and receives updates from other controllers.
Supports Snapcast 0.15.0
.
Install
pip install snapcast
Usage
Control
import asyncio
import snapcast.control
loop = asyncio.get_event_loop()
server = loop.run_until_complete(snapcast.control.create_server(loop, 'localhost'))
# print all client names
for client in server.clients:
print(client.friendly_name)
# set volume for client #0 to 50%
client = server.clients[0]
percent = 50
loop.run_until_complete(client.set_volume(percent))
# create background task (polling)
async def testloop():
while(1):
print("still running")
#print(json.dumps(server.streams[0].properties, indent=4))
print(server.groups)
await asyncio.sleep(10)
test = loop.create_task(testloop())
# add callback for client #0 volume change
def my_update_func(client):
print(client.volume)
server.clients[0].set_callback(my_update_func)
# keep loop running to receive callbacks and to keep background task alive
loop.run_forever()
Client
Note: This is experimental. Synchronization is not yet supported. Requires GStreamer 1.0.
import snapcast.client
client = snapcast.client.Client('localhost', snapcast.client.SERVER_PORT)
client.register()
client.request_start() # this blocks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
snapcast_mod-2.4.6.tar.gz
(16.9 kB
view details)
Built Distribution
File details
Details for the file snapcast_mod-2.4.6.tar.gz
.
File metadata
- Download URL: snapcast_mod-2.4.6.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94bc0172204e5057e6d4f14497f60c1f775f315adbd5d12d756e36e354d630ec |
|
MD5 | 28e6cc9629aceb9014014deec23dacce |
|
BLAKE2b-256 | afaa79603a55159d79c81f98fb1720ed2b608a4f533c628c0bd354f8c09d81b5 |
File details
Details for the file snapcast_mod-2.4.6-py3-none-any.whl
.
File metadata
- Download URL: snapcast_mod-2.4.6-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edf96dfb692a91ffe5c88480e9863f8c9b1fc5563b3cfa5e9b6017946ae5fb15 |
|
MD5 | 8e84bd09d1845351ec02ea8f4cb1ea08 |
|
BLAKE2b-256 | adaea9db22b3abed1e027f9e7a34fa597b7e450e0bb32ff9d5ac06bcde1e0c69 |