Crate bose_soundtouch

Crate bose_soundtouch 

Source
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
BassCapabilities
Bass capabilities of the device
BoseClient
Client for interacting with Bose SoundTouch devices
Component
Individual component information
Components
Component version information
ConnectionState
Network connection state information
ContentItem
Content item representing a media source or track
DeviceInfo
Information about the device
NetworkInfo
Network information for the device
NowPlaying
Current playback information
NowPlayingContentItem
Content item details for currently playing media
NowPlayingUpdate
Now playing update event from the device
PostKey
PostVolume
Preset
Individual preset station/source
PresetContentItem
Content details for a preset
PresetContentItemValue
Presets
Collection of preset stations/sources
Recent
Recently played item
Recents
Collection of recently played items
RecentsUpdate
Recents update event from the device
SdkInfo
Information about the SoundTouch SDK version
SourceItem
Individual source item
Sources
Available sources for the SoundTouch device
Updates
Collection of updates received from the device
UserActivity
User activity event from the device
Volume
Volume settings for the device
VolumeUpdate
Volume update event from the device
Zone
Zone configuration for multi-room audio
ZoneMember
Member device in a multi-room zone

Enums§

ArtStatus
Status of artwork
BoseClientError
Errors that can occur when using the SoundTouch API
BoseError
Errors that can occur when using the SoundTouch API
ConnectionStateType
Network connection states
ContentItemType
Content item types
KeyValue
Remote control key values supported by the SoundTouch API
PlayStatus
Playback status
SignalStrength
Signal strength levels
SoundTouchEvent
Events that can be received from the device’s WebSocket API
Source
Source type for media content
SourceStatus
Status of a source
StreamType
Media stream types

Type Aliases§

Result
Result type for SoundTouch API operations