Introducing a new way to review your PRs.

Read the announcement

metrolistgroup / metrolist

Material Design YouTube Music client for Android, iOS and desktop

View on GitHub

19 documents · Updated Nov 4, 2026

docs / player-presentation

Player presentation and interaction

The player presentation turns shared playback state into a persistent now-playing surface. It gives the user a compact mini player, an expanded player with artwork and controls, and a queue editor while keeping playback decisions in the playback service behind PlayerConnection. See User experience, Compose navigation and screens, and Widgets and companion services for related product surfaces.

Player presentation surface

The player is a bottom sheet owned by the main activity. It stays available while the user moves between app screens, collapses to a mini player, and expands into the full now-playing view. The activity supplies the player connection through a Compose local, so player UI components observe one shared source of playback state. References: app/…/MainActivity.kt• L268-310, app/…/MainActivity.kt• L1036-1048, app/…/MainActivity.kt• L1201-1275, app/…/Player.kt• L209-223

Mini player

The mini player is the compact return point for playback. It shows the current artwork and song details with progress, opens the expanded player when tapped, and can change tracks with a horizontal swipe when the queue allows it. Its play button uses local playback or Cast state as the active source, while a Listen Together guest changes that action to mute or unmute. References: app/…/MiniPlayer.kt• L142-169, app/…/MiniPlayer.kt• L197-221, app/…/MiniPlayer.kt• L305-489, app/…/MiniPlayer.kt• L498-620

Expanded player

The expanded player combines artwork or inline lyrics with track details, progress, transport controls, and actions for the current item. It supports portrait and landscape layouts, full-screen lyrics, and artwork-based backgrounds. The display reads metadata and playback flows; button actions go through the connection or its active playback target instead of changing shared playback state in the UI. References: app/…/Player.kt• L324-411, app/…/Player.kt• L837-941, app/…/Player.kt• L1434-1555, app/…/Player.kt• L1586-1907, app/…/Player.kt• L1909-2032

Now-playing artwork

The artwork view presents the current item and the nearby queue items as a horizontally snapped surface. A user swipe moves the playback item only when the player reports a valid previous or next action. If playback reports an error, the artwork view is replaced by an error panel with retry and copy-report actions. References: app/…/Thumbnail.kt• L199-318, app/…/Thumbnail.kt• L322-431, app/…/PlaybackError.kt• L49-103, app/…/PlaybackError.kt• L174-209

Playback state boundary

PlayerConnection is the presentation boundary for the active player. It exposes state flows for the current metadata, play state, queue windows, current index, skip availability, repeat and shuffle modes, errors, lyrics, and database-backed current-song details. It also routes user commands to local playback or Cast when casting is active. References: app/…/PlayerConnection.kt• L94-198, app/…/PlayerConnection.kt• L225-240, app/…/PlayerConnection.kt• L320-413

The presentation layer follows a simple direction of flow:

flowchart LR
    Service[Music service and active player] --> Connection[PlayerConnection state and commands]
    Connection --> UI[Mini player and expanded player]
    Connection --> QueueUI[Queue and now-playing artwork]
    UI --> Connection
    QueueUI --> Connection
    Connection --> Cast[Cast or local playback target]

The connection reports effective playback from the local player unless Cast is active. The UI therefore uses Cast position and play state while casting, and local position and play state otherwise. Presentation state such as sheet expansion, lyrics visibility, and a dragged slider value remains separate from playback state. References: app/…/PlayerConnection.kt• L149-160, app/…/Player.kt• L265-398, app/…/Player.kt• L748-807

Playback commands

The UI sends commands through a small set of shared actions. These actions preserve the playback boundary for local playback, Cast, queue changes, and shared-listening restrictions.

User intentPresentation actionPlayback owner
Play or pauseToggle the connection or active Cast targetPlayerConnection and the active target
SeekCommit the slider valuePlayerConnection or Cast
Previous or nextUse skip helpersPlayerConnection and the service
Start a queuePass a Queue to the connectionMusicService
Add or play nextPass media items to the connectionMusicService
Like, save, or muteCall the matching connection actionMusicService or the database

Guest mode is part of this boundary. A Listen Together guest cannot change shared playback or queue order, and the main play control becomes a local mute control. Internal synchronization can still pass through the connection so remote state can reach the player. References: app/…/PlayerConnection.kt• L197-205, app/…/PlayerConnection.kt• L242-317, app/…/PlayerConnection.kt• L328-363, app/…/Player.kt• L994-1004, app/…/Player.kt• L1660-1772, app/…/Queue.kt• L170-197

Queue interaction

The queue surface makes the active timeline understandable and editable. It marks the current item, follows the current position as playback changes, and provides direct actions for selection, reordering, removal, shuffle, repeat, sleep timer, lyrics, and item menus. The queue view reflects the Media3 timeline; it does not maintain a second playback queue as its source of truth. References: app/…/Queue.kt• L145-180, app/…/Queue.kt• L657-743, app/…/PlayerConnection.kt• L623-645

When a user acts on a queue item, the presentation maps the gesture to a player operation:

  1. Tapping the current item toggles playback. Tapping another item moves playback to that timeline window.
  2. Dragging changes the visible order and commits the move when the drag ends.
  3. Swiping removes an item when queue editing is unlocked and offers a short undo action.
  4. Long pressing enters selection mode for actions that apply to several items.
  5. Suggested automix items can play next or enter the main queue.

The player service owns queue loading and continuation. A Queue describes how to obtain an initial status and later pages, while the service installs the resulting media items and exposes the queue title and timeline to the UI. References: app/…/Queue.kt• L772-943, app/…/Queue.kt• L946-1025, app/…/Queue.kt• L12-45, app/…/MusicService.kt• L1761-1834

Lyrics presentation

Inline lyrics are an alternate view inside the expanded player. The view reads lyrics tied to the current media item, fetches missing lyrics in the background, and can prefetch the next queue item while the lyrics pane is visible in the foreground. Playback position remains the timing source for the lyrics view. References: app/…/Player.kt• L2034-2056, app/…/Player.kt• L2063-2204

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to PlayerConnection state or command routing must preserve the local-versus-Cast meaning of effective playback.
  • Changes to queue timeline updates must keep the current window, queue order, and visible queue selection aligned.
  • Changes to guest restrictions must cover both the expanded controls and mini-player gestures.
  • Changes to the bottom-sheet host must keep the player present across navigation and keep its insets separate from the navigation bar.
  • Changes to slider position handling must preserve the distinction between a temporary drag value and a committed seek.
  • Changes to lyrics visibility or foreground loading must keep active lyrics timing separate from next-track prefetch.

Important failure modes

TriggerConsequenceGuard
UI reads local play state while Cast is activeThe controls show the wrong play status or progressUse the effective state and Cast position when casting
Queue editing ignores the current timeline indexA tap, move, or remove operation affects a different itemMap visible queue windows back to the player window or period index
A Listen Together guest uses a normal playback actionThe guest changes shared playback instead of only changing local audioDisable shared actions and use the guest mute path
A playback error reaches the player surface without retry contextThe user sees failure but has no clear recovery or report pathRender PlaybackError with retry and copy-report actions
Slider updates overwrite the value during a dragThe thumb jumps and the committed seek is wrongKeep the drag value separate until the seek finishes
Lyrics prefetch runs outside the visible foreground viewBackground work competes with active lyrics loadingLimit next-track prefetch to the visible lyrics pane and foreground app

Key files

FileWhy to read it
app/…/Player.ktMain expanded player, controls, progress, lyrics mode, full-screen behavior, and player-to-queue composition
app/…/MiniPlayer.ktCompact now-playing surface, play control, swipe navigation, and Cast or guest behavior
app/…/Queue.ktQueue display, item actions, editing, selection, and queue controls
app/…/Thumbnail.ktArtwork carousel and current-item navigation
app/…/PlayerConnection.ktShared state exposed to Compose and command boundary for playback
app/…/MusicService.ktQueue installation, queue continuation, automix, and playback ownership
app/…/Queue.ktContract used to turn a requested source into playable queue status and pages
app/…/MainActivity.ktPlayer lifetime, Compose state provision, and bottom-sheet placement