All Projects → happyleavesaoc → python-snapcast

happyleavesaoc / python-snapcast

Licence: MIT license
Python API for controlling Snapcast, a multi-room synchronous audio solution.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to python-snapcast

spotifypiHome
"Install and go" multiroom music playback solution, with support for spotify, airplay and bluetooth.
Stars: ✭ 32 (-42.86%)
Mutual labels:  snapcast
gst-sync-server
A library for synchronised network playback applications
Stars: ✭ 56 (+0%)
Mutual labels:  multi-room-audio
shairport-sync
AirPlay audio player. Shairport Sync adds multi-room capability with Audio Synchronisation
Stars: ✭ 5,532 (+9778.57%)
Mutual labels:  multi-room-audio
snapcast-pi
This project uses buildroot to build snapcast for the raspberry pi.
Stars: ✭ 19 (-66.07%)
Mutual labels:  snapcast
snapdroid
Snapcast client for Android
Stars: ✭ 84 (+50%)
Mutual labels:  snapcast
snapos
Snapcast OS
Stars: ✭ 73 (+30.36%)
Mutual labels:  snapcast
HydraPlay
A multiroom audio player setup, based on snapcast and mopidy.
Stars: ✭ 102 (+82.14%)
Mutual labels:  snapcast

Build Status PyPI version

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]
loop.run_until_complete(server.client_volume(client.identifier, {'percent': 50, 'muted': False}))

# 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].