Overview
The music player components provide a comprehensive audio playback interface with full-screen and minimized views. These components integrate with thePlayerController to manage playback state, track information, and user interactions.
MusicPlayerScreen
Full-screen music player interface with album artwork, playback controls, lyrics, and track management. Location:ui/screens/MusicPlayerScreen.kt:59
Parameters
Callback invoked when the user collapses the player screen
Controller instance managing playback state and operations
Features
- Dual-page interface: Swipeable horizontal pager with Player and Lyrics pages
- Dynamic background: Blurred album artwork with gradient overlay
- Playback controls: Play/pause, skip, shuffle, and repeat controls
- Progress slider: Seekable progress bar with current/total time display
- Playlist management: Add current track to playlists via menu options
- Favorite toggle: Like/unlike tracks directly from the player
- Lyrics view: Synchronized lyrics display with tap-to-seek functionality
State Management
The component observesplayerController.playerState for:
currentTrack: Currently playing track informationisPlaying: Playback statecurrentPosition: Playback position in millisecondsduration: Track duration in millisecondsisShuffleEnabled: Shuffle mode staterepeatMode: Repeat mode (OFF, ALL, ONE)playingSource: Source context (e.g., “Local Music”, playlist name)lyrics: Synchronized lyrics datacurrentLyricIndex: Active lyric line indexisCurrentTrackFavorite: Favorite status
Usage Example
Player Page Layout
The primary player page (page 0) includes:- Header: Collapse button, “Playing from” source label, options menu
- Album art: 75% width, rounded corners with shadow
- Track info: Title, artist, favorite button
- Progress bar: Slider with time labels
- Controls row: Shuffle, previous, play/pause, next, repeat
Lyrics Page Layout
The lyrics page (page 1) includes:- Compact track header with artwork and title
LyricsScreencomponent with synchronized lyrics- Click-to-seek functionality at specific lyric timestamps
Menu Options
Accessed via the three-dot menu in the header:- Add to Playlist: Opens
AddToPlaylistBottomSheetfor playlist selection
MiniPlayer
Compact player bar displaying current track with basic playback controls. Location:ui/screens/MiniPlayer.kt:37
Parameters
Callback invoked when the mini player is tapped (typically expands to full player)
Controller instance managing playback state and operations
Features
- Auto-hide: Only displays when a track is currently loaded
- Compact design: 64dp height with rounded corners
- Progress indicator: 2dp progress bar at bottom edge
- Quick controls: Play/pause and skip next buttons
- Glassy appearance: Semi-transparent background with 90% opacity
Layout Structure
From left to right:- Album artwork: 48x48dp with 8dp rounded corners
- Track info: Title (bold, 14sp) and artist (12sp, gray)
- Play/pause button: Icon toggles based on playback state
- Skip next button: Advances to next track
Progress Bar
A thin progress indicator spans the full width at the bottom:- Height: 2dp
- Background: White at 10% opacity
- Active color: Primary theme color
- Width: Calculated as
currentPosition / duration
Usage Example
Styling
- Container:
Color(0xFF1E1E1E).copy(alpha = 0.90f) - Corner radius: 12dp
- Padding: 8dp horizontal, 4dp vertical outer padding
- Clickable: Entire container expands player on tap
PlayerController Integration
Both components rely onPlayerController singleton for state and operations:
Core Operations
State Collection
Related Components
- Track List - Track list item rendering
- Dialogs - Playlist and track management dialogs