Expand description
An easy to use client for the Bose SoundTouch API.
§Getting started
Add bose_soundtouch to your Cargo.toml:
[dependencies]
bose_soundtouch = { version = "1", features = ["websocket"] }
tokio = { version = "1", features = ["full"] }§HTTP API Example
use bose_soundtouch::BoseClient;
#[tokio::main]
async fn main() {
let client = BoseClient::new_from_string("192.168.1.143");
let status = client.get_status().await.unwrap();
println!("status: {:?}", status);
}§WebSocket API Example
use bose_soundtouch::{BoseClient, SoundTouchEvent};
use tokio;
#[tokio::main]
async fn main() {
// Create a new client
let mut client = BoseClient::new_from_string("bose-speaker.local");
// Subscribe to events
let mut rx = client.subscribe();
// Start listening in background
let mut ws_client = BoseClient::new_from_string(client.hostname());
let _rx = ws_client.subscribe();
tokio::spawn(async move {
if let Err(e) = ws_client.connect_and_listen().await {
eprintln!("WebSocket error: {}", e);
}
});
// Handle events
while let Ok(event) = rx.recv().await {
match event {
SoundTouchEvent::NowPlayingUpdated(update) => {
println!("Now playing: {} - {}",
update.now_playing.artist.unwrap_or_default(),
update.now_playing.track.unwrap_or_default());
}
SoundTouchEvent::VolumeUpdated(vol) => {
println!("Volume: {}", vol.volume.actual_volume);
}
_ => {}
}
}
}
Structs§
- Art
- Artwork information
- Bass
- Bass settings for the device
- Bass
Capabilities - Bass capabilities of the device
- Bose
Client - Client for interacting with Bose SoundTouch devices
- Component
- Individual component information
- Components
- Component version information
- Connection
State - Network connection state information
- Content
Item - Content item representing a media source or track
- Device
Info - Information about the device
- Network
Info - Network information for the device
- NowPlaying
- Current playback information
- NowPlaying
Content Item - Content item details for currently playing media
- NowPlaying
Update - Now playing update event from the device
- PostKey
- Post
Volume - Preset
- Individual preset station/source
- Preset
Content Item - Content details for a preset
- Preset
Content Item Value - Presets
- Collection of preset stations/sources
- Recent
- Recently played item
- Recents
- Collection of recently played items
- Recents
Update - Recents update event from the device
- SdkInfo
- Information about the SoundTouch SDK version
- Source
Item - Individual source item
- Sources
- Available sources for the SoundTouch device
- Updates
- Collection of updates received from the device
- User
Activity - User activity event from the device
- Volume
- Volume settings for the device
- Volume
Update - Volume update event from the device
- Zone
- Zone configuration for multi-room audio
- Zone
Member - Member device in a multi-room zone
Enums§
- ArtStatus
- Status of artwork
- Bose
Client Error - Errors that can occur when using the SoundTouch API
- Bose
Error - Errors that can occur when using the SoundTouch API
- Connection
State Type - Network connection states
- Content
Item Type - Content item types
- KeyValue
- Remote control key values supported by the SoundTouch API
- Play
Status - Playback status
- Signal
Strength - Signal strength levels
- Sound
Touch Event - Events that can be received from the device’s WebSocket API
- Source
- Source type for media content
- Source
Status - Status of a source
- Stream
Type - Media stream types
Type Aliases§
- Result
- Result type for SoundTouch API operations