Skip to main content

snapcastcontrol

Project description

SnapcastControl

SnapcastControl is a Python API for controlling snapcast over tcp 1705, snapcast is a multi-room synchronous audio solution made by baiax.

Installation

pip install snapcastcontrol

Usage

>>>

>>> import asyncio
>>> from SnapcastControl.control import SnapcastControl

>>># Simulation notification callback methods.
def testOnVolumeChange(data):
  percent = data['params'].get('volume').get('percent')
  muted   = data['params'].get('volume').get('muted')
  print(f"### This is a callback from SnapcastControl - Simulation onVolumeChange. - percent: {percent}, muted: {muted}")

def testOnClientConnect(data):
  client = data
  print(f"### This is a callback from SnapcastControl - Simulation of onClientConnect. - connected: {client.connected} ")


def testOnClientDisconnect(data):
  print(f"### This is a callback from SnapcastControl - Simulation of onClientDisconnect. - clientId: {data}")


def testOnServerUpdate(data):
  print(f"### This is a callback from SnapcastControl - Simulation of onServerUpdate. - Create a new server dissmis the Old.") # \n serverData: {serverData} ")

def testOnServerCreated(data):
  print(f"### This is a callback from SnapcastControl - Simulation of onServerCreated. - New Server Created ")


def testOnGroupMute(data):
  pass
def testOnServerDisconnect(data):
  pass


>>> Examples notificationCallbacks
testNotificationCallbacks = {
  'onVolumeChange':         testOnVolumeChange,
  'onServerDisconnect':     testOnServerDisconnect,
  'onGroupMute':            testOnGroupMute,
  'onClientConnect':        testOnClientConnect,
  'onClientDisconnect':     testOnServerDisconnect,
  'onServerUpdate':         testOnServerUpdate,
  'onServerCreated':        testOnServerCreated,



}

>>> Available notificationCallbacks.
  'onVolumeChange':
  'onLatencyChanged':
  'onServerDisconnect':
  'onGroupMute':
  'onClientConnect':
  'onClientDisconnect':
  'onServerUpdate':
  'onClientNameChanged':
  'onGroupStreamchanged':
  'onStreamUpdate':
  'onServerCreated':


>>> snapcastControl = SnapcastControl(1, "ThreadSnapcastControl", 'localhost', port=1705, reconnect=True, notificationCallbacks=testNotificationCallbacks)

>>> Her we use a time sleep, the snapcastControl must first start and initialize.
    time.sleep(0.1)

>>> asyncio.run_coroutine_threadsafe(snapcastControl.setVolumeAllClients(55, False), snapcastControl._loop)
>>> Other methods you can call threadsafe, for now
  async def setVolume(clientId, percent, mute):
  async def setVolumeAllClients(percent, mute):
  async def setClientLatency(clientId, latency):

📜 License. GPLv3

Ships under GPLv3, it means you are free to use and redistribute the code but are not allowed to use any part of it under a closed license.

Disclaimer.

This is work in progress and the code is as it is. Use it at your own risk/fun.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snapcastcontrol-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snapcastcontrol-0.1.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file snapcastcontrol-0.1.0.tar.gz.

File metadata

  • Download URL: snapcastcontrol-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for snapcastcontrol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8966d0a92fc59b1185a917530be6348ce0d328b3c19768e6220450e0498dd265
MD5 f1d1489a2f905b25fda30c16835c5a0e
BLAKE2b-256 c3913e73e3bd8fa565c09c86b31302801ac51e14eaf845aa7f679f26f872a0ec

See more details on using hashes here.

File details

Details for the file snapcastcontrol-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for snapcastcontrol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 888779c0b85917c4d78398a401c7dc326e560b734a8df1e83a50cb77ff0ba060
MD5 ae7f3c91cdd87d4dec2e6dfe52e180c2
BLAKE2b-256 0d2e1179e137eb092e8221326686710838b225e10e26f921931e1b133495076a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page