sonor

Crates.iosonor
lib.rssonor
version2.0.0
sourcesrc
created_at2020-04-28 13:34:24.445509
updated_at2023-09-16 14:09:07.895705
descriptiona library for controlling sonos speakers
homepage
repositoryhttps://github.com/jakobhellermann/sonor
max_upload_size
id234994
size89,318
Jakob Hellermann (jakobhellermann)

documentation

README

GitHub last commit Crates.io

This crate is a Sonos controller library written in Rust. It operates asynchronously and aims for a simple to use yet powerful API.

Example

let speaker = sonor::find("your room name", Duration::from_secs(2)).await?
    .expect("room exists");

println!("The volume is currently at {}", speaker.volume().await?);

match speaker.track().await? {
    Some(track_info) => println!("- Currently playing '{}", track_info.track()),
    None => println!("- No track currently playing"),
}

speaker.clear_queue().await?;

speaker.join("some other room").await?;

For a full list of actions implemented, look at the Speaker docs.

If your use case isn't covered, this crate also exposes the raw UPnP Action API here. It can be used like this:

use sonor::URN;

let service = URN::service("schemas-upnp-org", "GroupRenderingControl", 1);
let args = "<InstanceID>0</InstanceID>";
let response = speaker.action(&service, "GetGroupMute", args).await?;

println!("{}", response["CurrentMute"]);
Commit count: 70

cargo fmt