Expand description
Snapcast client library — embeddable synchronized multiroom audio client.
See also: snapcast-server for the server library.
Snapcast client library — embeddable synchronized multiroom audio.
§Example
use snapcast_client::{SnapClient, ClientConfig, ClientEvent, ClientCommand};
let config = ClientConfig::default();
let (mut client, mut events, mut audio_rx) = SnapClient::new(config);
let cmd = client.command_sender();
// React to events in a separate task
tokio::spawn(async move {
while let Some(event) = events.recv().await {
match event {
ClientEvent::VolumeChanged { volume, muted } => {
println!("Volume: {volume}, muted: {muted}");
}
_ => {}
}
}
});
// Stop on Ctrl-C
let stop = cmd.clone();
tokio::spawn(async move {
tokio::signal::ctrl_c().await.ok();
stop.send(ClientCommand::Stop).await.ok();
});
client.run().await?;Modules§
- config
- Client configuration types mirroring the C++
ClientSettings. - connection
- Connection layer — TCP, WebSocket, and WSS implementations.
- decoder
- Audio decoder trait and implementations.
- discovery
- mDNS/ZeroConf service discovery for finding snapservers.
- stream
- Time-synchronized PCM audio stream buffer.
- time_
provider - Server time synchronization.
Structs§
- Audio
Frame - Interleaved f32 audio frame produced by the client library.
- Client
Config - Configuration for the embeddable client.
- Sample
Format - Audio sample format: rate, bit depth, and channel count.
- Snap
Client - The embeddable Snapcast client.
Enums§
- Client
Command - Commands the consumer sends to the client.
- Client
Event - Events emitted by the client to the consumer.
Constants§
- DEFAULT_
STREAM_ PORT - Default TCP port for binary protocol (streaming clients).
- PROTOCOL_
VERSION - Snapcast binary protocol version.