Widgets, lyrics, recognition, and listening together
Metrolist extends music playback beyond its main screens. Home-screen widgets and shortcuts give fast access to playback and search. Lyrics, recognition, Discord presence, and Listen Together add context, sharing, and group playback around the same player.
External access points
Widgets and launcher shortcuts
Widgets keep common playback actions visible outside the app. The music player widget and turntable widget reflect the current song and offer playback controls. The playlist widget adds quick picks from local playlists, liked songs, downloads, and listening history. The recognition widget starts a separate song search and shows its result.
Widget state follows the player while the playback service is active. A widget tap sends an action back to that service, so the home screen and the in-app player use the same playback state. Widget size changes the amount of information shown rather than changing the feature’s role. (app/…/MetrolistWidgetManager.kt• L52-121, app/…/PlaylistWidgetManager.kt• L133-175, app/…/MusicWidgetReceiver.kt• L18-79)
Launcher shortcuts provide direct entry to Search and Library. The Quick Settings recognition tile provides another path to the recognition flow, while recognition links from the widget open the recognition screen or its saved result. (app/…/shortcuts.xml• L2-23, app/…/MusicRecognizerTileService.kt• L12-41, app/…/MusicRecognizerWidgetReceiver.kt• L311-334)
References: app/…/MetrolistWidgetManager.kt• L52-121 app/…/PlaylistWidgetManager.kt• L133-175 app/…/MusicRecognizerWidgetReceiver.kt• L138-167 app/…/shortcuts.xml• L2-23
Recognition flow
Music recognition identifies a song from sound captured by the device microphone. The flow records a short sample, prepares it for fingerprint matching, sends the fingerprint to the recognition service, and exposes either a match, no match, or an error. A foreground notification makes the microphone use and current state visible while recognition runs. (app/…/MusicRecognitionService.kt• L60-155, app/…/RecognitionForegroundService.kt• L74-200)
The same recognition service supports the in-app screen, the home-screen widget, and the Quick Settings tile. A successful result can be saved to recognition history, so the widget is both a capture tool and a path back to the app’s saved result. Microphone permission is a required boundary; without it, external entry points send the user to the app to grant access. (app/…/MusicRecognizerWidgetReceiver.kt• L95-133, app/…/AndroidManifest.xml• L344-376)
The flow below shows how an external trigger becomes a user-visible recognition result.
flowchart LR
A[Widget or Quick Settings tile] --> B[Recognition entry point]
B --> C[Microphone sample]
C --> D[Audio fingerprint]
D --> E[Recognition service]
E --> F{Result}
F -->|Match| G[Result and history]
F -->|No match| H[Retry message]
F -->|Failure| I[Error message]
References: app/…/MusicRecognitionService.kt• L39-155 app/…/RecognitionForegroundService.kt• L178-229 app/…/MusicRecognizerWidgetReceiver.kt• L95-133 app/…/AndroidManifest.xml• L344-376
Lyrics and translation
Lyrics retrieval
Lyrics retrieval turns the current song’s title, artist, album, and duration into a lyric result. A provider is an external or catalog-backed source of lyrics. The lyrics helper checks enabled providers in the user’s chosen order, stops at a usable result for the normal view, and caches recent results for reuse.
The provider registry gives the app a common set of sources, including BetterLyrics, LrcLib, KuGou, Paxsenix, LyricsPlus, Zemer, YouTube subtitles, and YouTube lyrics. The settings screen can change provider order, so source choice is a user preference rather than a fixed part of the player. Network loss or provider failure produces a clear unavailable result instead of blocking playback. (app/…/LyricsProviderRegistry.kt• L8-53, app/…/LyricsHelper.kt• L48-112, app/…/ContentSettings.kt• L669-721)
Lyrics may be plain text or time-synced text. The lyrics view parses timed lines when they are present and uses ordered lines when they are not. This lets the player show lyrics even when a source does not provide timing, while timed sources can follow playback. (app/…/LyricsViewModel.kt• L37-83)
References: app/…/LyricsHelper.kt• L33-112 app/…/LyricsProviderRegistry.kt• L8-53 app/…/LyricsViewModel.kt• L37-83 app/…/ContentSettings.kt• L669-721
Translation display
Translation adds a second line of meaning to the original lyrics without replacing them. The translation helper can load a saved translation, reuse a session result, or request a new translation through the selected translation service. It tracks language and mode so a saved result is used only when it matches the current request.
The lyrics screen can start, cancel, clear, and progressively show a translation. Missing credentials, empty lyrics, and service errors remain visible as translation errors; they do not change the original lyric result. (app/…/LyricsTranslationHelper.kt• L129-198, app/…/OriginalLyrics.kt• L363-418, app/…/LyricsMenu.kt• L492-518)
The translation path is therefore optional and layered: providers supply the original text first, then the translation service adds language support when the user asks for it.
flowchart LR
A[Original lyrics] --> B[Language and mode]
B --> C{Saved or cached translation?}
C -->|Yes| D[Load translated lines]
C -->|No| E[Translation service]
E --> F[Save and display translation]
D --> F
A --> G[Keep original lines visible]
References: app/…/LyricsTranslationHelper.kt• L129-198 app/…/LyricsTranslationHelper.kt• L220-257 app/…/OriginalLyrics.kt• L363-418 app/…/LyricsMenu.kt• L492-518
Presence and shared listening
Discord presence
Discord presence publishes the current listening activity to a user’s Discord profile. After OAuth authorization, the Discord manager maintains the connection and sends song details, playback timing, artwork, status, and optional buttons. The activity builder can use default values or user-defined templates for the displayed name and text.
Presence follows playback state and avoids sending unchanged updates too often. Settings control whether presence is enabled, how it is labeled, which activity type and status it uses, and whether links appear. The integration stores its authorization state so a later app start can reconnect. (app/…/DiscordRpcManager.kt• L135-159, app/…/DiscordRpcManager.kt• L298-320, app/…/DiscordActivityBuilder.kt• L9-110, app/…/DiscordSettings.kt• L134-200)
The presence payload is a view of playback, not a second player. If Discord is not authorized or ready, playback continues without the external update. (app/…/DiscordPresence.kt• L23-138)
References: app/…/DiscordRpcManager.kt• L135-159 app/…/DiscordRpcManager.kt• L298-320 app/…/DiscordActivityBuilder.kt• L9-110 app/…/DiscordSettings.kt• L134-200
Listen Together rooms
Listen Together lets people share one playback session in a room. One user is the host and controls the shared state. Other users join as guests, can wait for approval, and can suggest content subject to the host’s rules. The room uses a selectable server and a room code; invite links can open the same flow from outside the app. (app/…/ListenTogetherClient.kt• L68-219, app/…/ListenTogetherServers.kt• L11-40, app/…/ListenTogetherScreen.kt• L109-186, app/…/AndroidManifest.xml• L79-89)
The screen exposes connection state, room members, join requests, suggestions, and host actions. Settings cover the user name, server, join approval, suggestion approval, and host-volume sharing. A reconnecting client can restore a session instead of treating a short network loss as the end of the room. (app/…/ListenTogetherSettings.kt• L102-120, app/…/ListenTogetherClient.kt• L315-329)
References: app/…/ListenTogetherClient.kt• L68-219 app/…/ListenTogetherServers.kt• L11-40 app/…/ListenTogetherScreen.kt• L109-186 app/…/ListenTogetherSettings.kt• L102-120
Synchronized playback
The Listen Together manager connects room events to the local player. The host shares track changes, play and pause state, seeks, queue changes, and optional volume changes. Guests receive that state and the manager limits direct playback changes so the room stays under host control.
Synchronization accounts for the fact that each device buffers and plays its own copy of a track. Guests can wait for the other users to buffer, then correct small timing drift and seek when the difference becomes large. This keeps normal playback smooth while still recovering from a missed or delayed update. (app/…/ListenTogetherManager.kt• L63-69, app/…/ListenTogetherManager.kt• L161-227, app/…/ListenTogetherClient.kt• L196-212)
The shared-listening flow has a clear ownership boundary:
- The host changes the local playback state.
- The manager sends the change to the room service.
- Guests load or seek to the shared track and position.
- Buffer and drift events correct local timing without creating a feedback loop.
References: app/…/ListenTogetherManager.kt• L161-227 app/…/ListenTogetherManager.kt• L292-359 app/…/ListenTogetherClient.kt• L196-212
Change checklist
When these files or sections are changed, remember to consider these:
- Keep widget action names, manifest receiver declarations, and the player-service action handling aligned.
- Keep recognition state names consistent between the recognition service, foreground notification, widget display, and recognition history save path.
- Keep lyric provider names stable across the registry, stored provider order, and content settings migration behavior.
- Keep translation language and mode metadata aligned with the saved translated lines.
- Keep Discord activity templates, payload fields, and OAuth or gateway state changes compatible.
- Keep Listen Together host and guest rules aligned between room events, player blocking, queue sync, and deep-link entry.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Microphone permission is missing | Widget or tile cannot start recognition | Open the recognition screen so the user can grant permission. |
| Recognition service returns no match | No song enters recognition history | Show the no-match state and allow a new capture. |
| All lyric providers fail or the device is offline | Lyrics remain unavailable for the track | Use provider time limits, network checks, and the unavailable result. |
| Translation credentials or source text are missing | Original lyrics remain, but translated lines do not appear | Report a translation error without replacing the original. |
| Discord authorization or gateway readiness fails | Presence is not published | Keep playback independent and expose the integration error in settings. |
| A Listen Together guest changes playback locally | Room state can diverge from the host | Block guest playback changes while the guest is in a room. |
| A room connection drops | Shared playback pauses in its last known state until recovery | Reconnect and restore the persisted room session when possible. |
Key files
| File | Why to read it |
|---|---|
| app/…/MetrolistWidgetManager.kt | Main playback and turntable widget state flow |
| app/…/PlaylistWidgetManager.kt | Playlist widget quick picks and player state |
| app/…/MusicRecognizerWidgetReceiver.kt | Recognition widget entry points and visible states |
| app/…/shortcuts.xml | Launcher Search and Library shortcuts |
| app/…/LyricsHelper.kt | Provider selection, fallback, and lyric caching |
| app/…/LyricsTranslationHelper.kt | Translation request, cache, and saved-result behavior |
| app/…/MusicRecognitionService.kt | Audio-to-recognition flow |
| app/…/DiscordRpcManager.kt | Discord authorization, connection, and activity updates |
| app/…/ListenTogetherManager.kt | Room playback ownership and timing sync |
| app/…/ListenTogetherClient.kt | Room connection and shared event model |
| app/…/ListenTogetherScreen.kt | User-facing room lifecycle and host or guest actions |