A crossplatform app for streaming music
README.md

KiMusic #

A YouTube Music player for Android and Linux desktop, built with Kotlin and Compose Multiplatform. Inspired by ViMusic / RiMusic / Harmony-Music — the name is a nod to that line, though none of the code is theirs — with a resilient backend and a focus on low-latency, gapless playback.

Source: https://tangled.org/kimusic.tngl.sh/kimusic. The name, the package id and the identity behind them are in ADR-0017.

Status: early development, and usable daily on both platforms. Releases are published from v0.1.2 onwards, and the database schema still changes under migrations rather than being frozen.

What it does #

  • Plays from YouTube Music, gaplessly: two warm engines hand over to each other, the next track's head is prefetched, and the crossfade is configurable (0-12s).
  • Keeps a library on the device — songs, playlists, favourites, history and every listen with the time it happened — with a Home built from it, and radio from any song.
  • Syncs across devices through a server you run, which holds the library sealed and cannot read any of it. Devices are enrolled by holding a QR code up to a camera; merging happens on the devices, and listening from two of them adds up rather than one winning (ADR-0010, spec).
  • Imports a RiMusic .db, a Harmony-Music .hmb or a portable bundle, and works out which one it is. Exports the same bundle back (spec).
  • Caches and downloads: everything played is cached to disk under a size you set, and tracks can be kept offline in storage the OS cannot reclaim (ADR-0015).
  • Shows lyrics, from the library first and LRCLIB second, timed and following the song where the source has timings (ADR-0016).
  • Counts the listening — a Stats tab over any month, any year or all of it, with the months worth keeping saveable as playlists. History imported from another app is included, back to 2022 where the backup has dates.
  • Scrobbles to ListenBrainz, queued on the device so nothing is lost offline, paced by the service's own rate-limit headers, and able to send past listening in one go (ADR-0018).
  • Suggests what to play next from the ListenBrainz playlists built for the account — Weekly Jams, Daily Jams, Weekly Exploration — matched to YouTube by artist, title and duration, and honest enough to leave out what it cannot match rather than offering the wrong recording.
  • Stops on its own, after a set time or at the end of the track, fading out rather than cutting off.
  • Waits out a lost network instead of walking the queue: a track that cannot be resolved holds where it is, and starts by itself when the connection comes back (ADR-0019).
  • Behaves like a music app on Android: media notification, lock screen controls, audio focus, and a foreground service that keeps downloads alive.

Goals (in priority order) #

  1. Resilient backend — never vendor a one-person YouTube client. Use NewPipeExtractor (TeamNewPipe, actively maintained) + yt-dlp fallback.
  2. Low-latency, seam-friendly playback — two warm engines + prefetch of the next track's head + configurable crossfade, backed by a local stream proxy that caches to disk (instant replays).
  3. Cross-platform — Android and desktop share about 80% of the Kotlin by line count; the rest is the two audio engines and the platform plumbing.
  4. Data portability — import from RiMusic / Harmony-Music, export the same bundle back, and sync across devices through a server you host yourself and that cannot read what it stores (ADR-0010).

Quick start #

# Desktop (Linux)
./gradlew :composeApp:run

# Android, onto a connected device
./gradlew :composeApp:installDebug

# Optional: merge SEVERAL backups into one bundle up front. The app imports a
# RiMusic .db, a Harmony .hmb or a bundle directly (Settings → Import backup…).
./gradlew :tools:run --args="--rimusic /path/rimusic.db --harmony /path/backup.hmb --out build/bundle.json"

# Tests
./gradlew :core:jvmTest :data:jvmTest :extractor:jvmTest :composeApp:desktopTest

The APK is split per ABI, so there is no single composeApp-debug.apk to install by hand; installDebug picks the right one for the device. To share a build, take the arm64-v8a APK from composeApp/build/outputs/apk/debug/.

See docs/DEVELOPMENT.md for prerequisites (JDK 21, Android SDK, device setup) and troubleshooting.

Documentation #

Layout #

composeApp/    UI (Compose Multiplatform; androidMain / desktopMain entry points)
core/          PlayerEngine + GaplessController (A/B, preload, crossfade),
               libmpv (JNA) engine, stream proxy, cache and downloads
extractor/     YtMusicApi over NewPipeExtractor, yt-dlp fallback, LRCLIB lyrics
data/          PortableBundle model, RiMusic(.db) / Harmony-Music(.hmb) importers,
               on-device library (SQLDelight + lyrics files)
log/           the logging facade, which everything else depends on
tools/         CLI: merge backups → portable-bundle.json
server/        the sync server: an append-only log it cannot read (FastAPI)
scripts/       release.sh — builds and checksums the artifacts for a tag
design/        the logo, and the script that turns it into app icons

License #

Copyright (C) 2026 KiMusic contributors.

GPL-3.0-or-later — the full text is in LICENSE. The app is a derivative of GPL work (NewPipeExtractor, libmpv, yt-dlp) and the wider open-source YouTube-Music player family, so no other license was available; the reasoning is in ADR-0007. That also rules out the Play Store, whose terms are incompatible with the GPL.

This is a client for a service it does not own. It plays what YouTube serves, and nothing here is an invitation to ignore whatever rights attach to it.