Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

happyleavesaoc/python-snapcast

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

162 Commits
162 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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]
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()

See example.py for a basic working example.

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

About

Python API for controlling Snapcast, a multi-room synchronous audio solution.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.