Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/6xingyv/accompanist-lyrics-ui/llms.txt

Use this file to discover all available pages before exploring further.

The Accompanist sample app is a complete music player that showcases every major capability of the lyrics-ui library. It pairs a KaraokeLyricsView with real-time ExoPlayer playback, an animated album-art background, a social sharing flow, and a fully adaptive layout that works on phones and tablets — giving you a battle-tested reference for your own integration.

What’s Included

Player Screen

Full-screen lyrics view with album art thumbnail, song/artist metadata, playback seek-on-tap, and per-syllable karaoke animation powered by KaraokeLyricsView.

FlowingLightBackground

A dynamic animated background that samples the album-art bitmap, applies saturation and darkening filters based on the art’s luminance, and blurs multiple copies at different scales to create a cinematic depth effect.

ShareScreen

Capture one or more lyric lines as a shareable image card. Two card styles are available: an Apple-music-inspired card and a Spotify-inspired dark card. Users can save to the gallery or invoke the system share sheet.

Adaptive Layout

Automatically switches between a phone layout (full-screen lyrics with compact header) and a tablet/desktop layout (album art on the left, lyrics on the right in a Row) using LocalWindowLayoutType.

Song Selection Dialog

A MusicItemSelectionDialog lets users choose from the bundled sample tracks or load a completely custom audio + lyrics file (and optional translation) from device storage. Custom files are picked via Android’s ActivityResultContracts.GetContent and parsed at runtime by AutoParser.

Sample Tracks

The following tracks are bundled under sample/src/androidMain/assets/ and are loaded by MusicRepositoryImpl at runtime:
TrackFile(s)Format & Notes
Golden Hour (Acapella Version)golden-hour.m4a + golden-hour.ttmlTTML (AMLL dialect) — single singer, with accompaniment lines and independent punctuation tokens
好久没下雨了 (Haven’t Rained for So Long)havent-rain-for-so-long.mp3 + havent-rain-for-so-long.ttmlTTML — single singer, CJK text with breathing-dot markers
La Pelirrojala-pelirroja.mp3 + la-pelirroja.ttmlTTML v1 — single singer
ME!me.mp3 + me.lys + me-translation.lrcLYS (Lyricify Syllable) native format — duo singer with accompaniment; translation injected from a separate LRC file
Track metadata (label, format description, media URI, lyrics asset path, and optional translation asset path) is declared in MusicRepositoryImpl.getMusicItems(). The AutoParser automatically detects the lyrics format (TTML, LYS, LRC, etc.) so no format-specific parsing code is needed at the call site.

Running the Sample

1

Download the demo APK

Grab the latest pre-built APK directly from GitHub Releases — no build tooling required:Download Demo APK →Install it on any Android device running API 29 (Android 10) or higher.
2

Build from source

Clone the repository and open the project in Android Studio. Select the sample run configuration, choose an Android device or emulator, and press Run.
git clone https://github.com/6xingyv/Accompanist.git
cd Accompanist
# Open in Android Studio, or run from CLI:
./gradlew :sample:installDebug
3

Run the desktop JVM target

The sample ships a minimal desktop entry point (MainKt) that renders a hardcoded TTML lyrics string using KaraokeLyricsView — useful for quickly previewing lyrics rendering on desktop without Android hardware. Run it with:
./gradlew :sample:run
The desktop entry point is a standalone lyrics-rendering preview. It does not include the full player, media playback, or share-sheet features — those are Android-only and live in androidMain.

Architecture

The sample follows a clean, unidirectional-data-flow architecture:
LayerClass / ComponentResponsibility
ViewModelPlayerViewModelHolds PlayerUiState as a StateFlow; bridges Media3 MediaController events to UI state; owns position-update and luminance-calculation coroutines
RepositoryMusicRepository / MusicRepositoryImplLoads MusicItem metadata and parses lyrics files via AutoParser
DIKoin dataModule + uiModuleWires MusicRepository, PlayerViewModel, and ShareViewModel as Koin-managed singletons/ViewModels
AudioMedia3 ExoPlayer + PlaybackServiceBackground playback as a MediaSessionService; MediaController connects the ViewModel to the service
UIPlayerScreen, ShareScreenStateless Composables driven by uiState; communicate back via ViewModel methods
The sample uses Koin for dependency injection — PlayerViewModel and ShareViewModel are declared in uiModule and injected into Composables via koinViewModel(). Audio playback is handled by Media3 ExoPlayer running in a bound PlaybackService, keeping audio alive when the app is backgrounded.

Build docs developers (and LLMs) love