17 unstable releases (8 breaking)

Uses new Rust 2024

0.8.0 Nov 10, 2025
0.6.0 Oct 30, 2024
0.4.2 Jul 29, 2022
0.3.1 Oct 24, 2021
0.0.0 Feb 24, 2018

#1559 in Audio

Download history 1005/week @ 2025-09-21 908/week @ 2025-09-28 923/week @ 2025-10-05 953/week @ 2025-10-12 995/week @ 2025-10-19 866/week @ 2025-10-26 1106/week @ 2025-11-02 1594/week @ 2025-11-09 1352/week @ 2025-11-16 1048/week @ 2025-11-23 961/week @ 2025-11-30 1117/week @ 2025-12-07 977/week @ 2025-12-14 1228/week @ 2025-12-21 1196/week @ 2025-12-28 1232/week @ 2026-01-04

4,754 downloads per month
Used in 9 crates (6 directly)

MIT license

780KB
17K SLoC

Connect

The connect module of librespot. Provides the option to create your own connect device and stream to it like any other official spotify client.

The Spirc is the entrypoint to creating your own connect device. It can be configured with the given ConnectConfig options and requires some additional data to start up the device.

When creating a new Spirc it returns two items. The Spirc itself, which is can be used as to control the local connect device. And a Future, lets name it SpircTask, that starts and executes the event loop of the connect device when awaited.

A basic example in which the Spirc and SpircTask is used can be found here: examples/play_connect.rs.

Example

use std::{future::Future, thread};

use librespot_connect::{ConnectConfig, Spirc};
use librespot_core::{authentication::Credentials, Error, Session, SessionConfig};
use librespot_playback::{
    audio_backend, mixer,
    config::{AudioFormat, PlayerConfig},
    mixer::{MixerConfig, NoOpVolume},
    player::Player
};

async fn create_basic_spirc() -> Result<(), Error> {
    let credentials = Credentials::with_access_token("access-token-here");
    let session = Session::new(SessionConfig::default(), None);

    let backend = audio_backend::find(None).expect("will default to rodio");

    let player = Player::new(
        PlayerConfig::default(),
        session.clone(),
        Box::new(NoOpVolume),
        move || {
            let format = AudioFormat::default();
            let device = None;
            backend(device, format)
        },
    );

    let mixer = mixer::find(None).expect("will default to SoftMixer");

    let (spirc, spirc_task): (Spirc, _) = Spirc::new(
        ConnectConfig::default(),
        session,
        credentials,
        player,
        mixer(MixerConfig::default())?
    ).await?;

    Ok(())
}

Dependencies

~36–76MB
~1M SLoC