Brendon-Hablutzel / rusty-sonos

A Rust crate for interacting with Sonos speakers
https://crates.io/crates/rusty-sonos
MIT License
1 stars 0 forks source link

Rusty-Sonos

crates.io Documentation MIT licensed

A library for discovering and interacting with Sonos speakers, written in Rust.

Features

The primary functionality of this library is to provide a wrapper for speaker discovery and speaker actions.

Discovery

To discover all speakers on the current network, use discover_devices(). This will return basic information about speakers (including IP addresses) about any speakers that were found. Internally, this uses the SSDP protocol.

To get information about a specific speaker, given its IP, use get_speaker_info().

Speaker Interaction

Interaction with speakers is done through a single struct, Speaker, which has methods for all the features that are currently implemented. To use Speaker, you must know the speaker's IP address (refer to the discovery section for how to find this):

use rusty_sonos::speaker::Speaker;
use std::net::Ipv4Addr;

let ip_addr = Ipv4Addr::from_str("192.168.1.0").unwrap();

let speaker = Speaker::new(ip_addr).await.unwrap();

speaker.play().await.unwrap(); // plays the current track

A non-exhaustive list and description of speaker methods is provided below:

Notes

Generally, the speakers' API is UPnP-based

These unofficial docs were used to build this library. They contain information about various services, endpoints, and responses.