Skip to content
mattix

andamp-source-librespot

Rust, Kotlin · Android, a separate APK · not on Google Play · mattijsf/andamp-source-librespot

A music source for the Android app of Alpaca, built on librespot, an open-source client library for a music streaming service. It plays your library from that service through Alpaca’s equalizer, effects and visualizers. You need a Premium account.

Once it’s installed, Alpaca lists it under Preferences > Music sources and in the Media Library. You sign in on this app’s one screen.

app/rustlibrespot
Speaks the service’s protocol and decodes the audio. Built without audio backends, discovery or Connect.
Kotlinthe source app
Holds the queue and Winamp’s transport rules, parses the library and keeps the credential.
Alpacathe player
Plays the samples through the same chain as a local file.
Settings screen of the librespot source: signed in as listener, sign out button, show in app list toggle

The source’s settings screen after sign-in, rendered by the Roborazzi snapshot test.

The official SDKs and controlling the service’s app through its media session both leave the audio inside the service’s app. Alpaca could start and stop playback, but would get no samples for the equalizer or the visualizer. With librespot embedded, the decoded samples come to Alpaca like those of any local file.

Rust for the protocol, Kotlin for the rest

Section titled “Rust for the protocol, Kotlin for the rest”

librespot is a submodule pinned to a dev commit, because the device-pair login isn’t in a release yet. Each local change is a patch file next to it, with a note on when it can go. The crate builds librespot’s core, playback, metadata and OAuth and leaves out the audio backends and discovery. The native library then links only liblog, libdl, libm and libc.

Rust and Kotlin talk in lines of text. Commands go down as JNI calls, events come back as lines that a small parser reads, and nothing calls back into the JVM. Library answers come back as the service’s JSON, and every Kotlin parser is tested against recorded responses.

librespot’s player holds one track and has no queue. The Kotlin side applies Winamp’s transport rules and tells the engine what changed. Next, previous and a track ending need no extra code, and the backend passes the same PlaybackBackendContractTest as Alpaca’s other backends.

  • Premium only. librespot doesn’t support free accounts, and upstream exits the process when it sees one. A patch turns that into an error message instead.
  • Since late 2025, librespot-based clients can’t get audio keys for many accounts created after roughly late 2024 (librespot#1649). Those tracks fail one at a time, and the source counts them.

The APK is on the extensions page on alpaca.fm, and isn’t on Google Play. Alpaca tells you when a newer version is out.

No trackers or cookies. Older designs of this site.