Playback Queue & Player Management
Audience: End users and technical evaluators Last Updated: 2026-04-04 Version: 2.0.0
Overview
Llamafin's player system manages playback queues, shuffle and repeat modes, multi-device playback targets, and provides intelligent features like auto-resume, gapless playback, and continuous autoplay.
Queue Management
Building Your Queue
Multiple ways to start listening:
| Action | What It Does |
|---|---|
| Play Album | Loads all tracks from the album into queue |
| Play Artist | Loads all songs from the artist |
| Play Playlist | Loads your curated playlist |
| Play Genre | Loads all songs matching the genre |
| Play Studio | Loads all albums from the record label/studio |
| Play Song | Single song playback (can add more later) |
| Play All Downloads | All your offline content |
| Play All From Library | Entire music library (up to 500 tracks) |
Queue Structure
Your playback queue contains:
- Full Track Metadata: Title, artist, album, artwork, duration, play counts
- Original Position Tracking: Remembers where each track came from
- Local File References: Points to downloaded copies when available
- Play Statistics: Times played, last played date
- Sonic Analysis Data: Audio fingerprints for similarity matching
Queue Operations
| Operation | Description |
|---|---|
| Play Next | Insert tracks immediately after current track |
| Add to Queue | Append tracks to the end of the queue |
| Clear Queue | Stop playback and remove all tracks |
| Stop & Clear | Graceful shutdown (closes player UI first) |
Shuffle Mode
Smart Shuffle Algorithm
Llamafin implements an intelligent shuffle that respects your listening history:
How It Works:
-
Turning Shuffle ON:
- Identifies your current position in the queue
- Preserves all tracks you've already heard (history)
- Randomly shuffles only the upcoming tracks
- You won't hear recently played tracks again
-
Turning Shuffle OFF:
- Restores the original order perfectly
- Uses original position tracking to rebuild sequence
- Returns to exactly how the album/playlist was ordered
Example:
Original Queue: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Currently at: [1, 2, 3] ← (playing track 3)
Shuffle ON: [1, 2, 3 | 7, 4, 9, 5, 10, 6, 8]
↑ History preserved ↑ Upcoming shuffled
Shuffle OFF: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
← Original order restored
Benefits:
- No duplicate listening in current session
- Easy return to original order
- Works with any queue size (minimum 2 tracks)
- Persists across app restarts
Repeat Modes
Three distinct repeat behaviors:
Repeat Off (Default)
Behaviour:
- Plays through queue normally
- Pauses when last track ends
- Rewinds to start of last track (position 0:00)
- Ready for manual selection
Best For:
- Intentional listening sessions
- Working through albums in order
- Following curated playlists
Repeat One
Behaviour:
- Replays current track indefinitely
- Doesn't advance to next track
- Manual intervention required to stop
Best For:
- Learning lyrics or musical parts
- Focusing on a single song
- Background ambiance
Repeat All
Behaviour:
- When last track ends, wraps to first track
- Continuous loop through entire queue
- Seamless transition (no pause at boundary)
- Shuffle and repeat work together
Best For:
- All-day background music
- Parties and events
- Shuffle + repeat for infinite variety
Playback Controls
Standard Controls
| Control | Function |
|---|---|
| Play | Resume paused playback |
| Pause | Pause at current position |
| Stop | Stop and clear queue |
| Next Track | Skip to next track in queue |
| Previous Track | Go back or restart current track |
| Seek | Jump to any position in track |
Previous Track Smart Behaviour
The previous button works intelligently:
If more than 5 seconds into track:
- Restarts current track from beginning
- Standard music player behaviour
- Quick access to track start
If less than 5 seconds into track:
- Goes to previous track in queue
- In shuffle mode: restarts current (previous is undefined)
- At queue start: restarts current track
Advanced Controls
| Control | Range | Function |
|---|---|---|
| Volume | 0% to 100% | Master playback volume |
| Mute Toggle | On/Off | Quick silence without losing volume setting |
| Seek Bar | 0:00 to track end | Scrub to any position |
Track Previews
Quick Audition System
Sample any track before committing to full playback:
Preview Features:
- 30-Second Duration: Enough to judge the track
- Isolated Playback: Doesn't affect your queue or current session
- Separate Audio Stream: Uses dedicated preview stream
- Visual Countdown: Shows remaining preview time
- Early Stop: Cancel preview anytime
Use Cases:
- Browse albums quickly
- Verify track before downloading
- Discover new music efficiently
- Avoid queue interruptions
Multi-Device Playback
Playback Targets
Llamafin can play music on different devices:
| Target | Description |
|---|---|
| Local | Play on current device (default) |
| Jellyfin Session | Remote control another Jellyfin client |
| Llamafin Connect | Control another Llamafin device directly |
Seamless Target Switching
All controls work regardless of target:
- Play/Pause/Stop: Routed to correct device
- Volume Control: Adjusted on target device
- Next/Previous: Queue management on target
- Seek: Position control on target
- Queue Operations: Managed locally, executed remotely
Unified Display
The player interface shows unified information:
- Current track (local or remote)
- Queue contents (synchronised)
- Playback progress (real-time)
- Volume level (target device)
Queue Persistence
Automatic State Saving
Your playback session is automatically preserved:
What Gets Saved:
- Complete playback queue (all tracks)
- Current track and position
- Shuffle mode status
- Repeat mode setting
- Playback target selection
- Autoplay queue flag
When It's Saved:
- Queue changes (new playlist, add/remove tracks)
- Track changes (next, previous)
- Mode changes (shuffle, repeat toggle)
- Target changes (switch playback device)
Session Restoration
When you reopen Llamafin:
- Stored State Loaded: Queue, modes, target restored
- Current Track Restored: Your last track selected
- Autoplay Check: If enabled, playback resumes automatically
- Manual Start: If autoplay off, press play to continue
Benefits:
- Never lose your place
- Resume listening instantly
- Perfect for commutes or work sessions
- Cross-restart persistence
Adjacent Track Preloading
Intelligent Buffering
Llamafin prepares upcoming tracks before you need them:
How It Works:
- When you start playing a track, the system identifies:
- Next track in queue
- Previous track in queue
- Both tracks are preloaded into the audio engine
- Next track is ready for instant playback
- Previous track cached for immediate skip-back
Benefits:
- Zero Delay: Next track starts instantly
- Smooth Experience: No loading pauses between tracks
- Instant Navigation: Skip forward/back immediately
- Gapless Playback: Seamless transitions enabled
Debounced Processing
Preloading is optimised:
- 250ms delay prevents excessive loading during rapid skips
- Only processes when all dependencies available (settings, network, user)
- Validates track data before preloading
- Graceful handling of missing tracks
Autoplay & Continuous Playback
Smart Queue Extension
Never run out of music automatically:
Detection:
- Monitors remaining tracks in queue
- Triggers when 5 or fewer tracks remain
- Checks if DJ mode is active
Priority System:
-
Single-Artist Queue:
- Detects if all tracks share same album artist
- Finds next/previous album from same artist
- Loads album tracks into queue
- Maintains artist context
-
Mixed-Artist Queue:
- Falls back to DJ mode
- Generates tracks based on current song
- Uses sonic similarity or smart algorithms
- Extends queue seamlessly
Album Autoplay:
- Sorts artist's albums by year and name
- Selects next album (configurable direction)
- Wraps around at end of discography
- Loads tracks maintaining album order
DJ Mode Fallback:
- If album autoplay fails or not applicable
- DJ generates tracks similar to current
- Uses audio fingerprinting
- Infinite music generation
Voice Search Playback
Speak to Play
Voice-activated music selection:
How It Works:
- Speak your request ("Play rock music" or "Play Beatles")
- Llamafin searches your library
- Results analyzed in priority order:
- Priority 1: Songs (offline first, then online)
- Priority 2: Albums
- Priority 3: Artists
- Priority 4: Playlists
- Best match starts playing immediately
Benefits:
- Hands-free music selection
- Quick access while driving
- Natural language queries
- Offline results prioritised
Self-Healing Playback
Automatic Error Recovery
Llamafin fixes problems without interrupting your music:
Missing Local File Detection:
- Track marked as downloaded but file is gone
- Happens if you delete downloads while in queue
- Detected when audio engine tries to play
Automatic Recovery:
- Strips stale local file references
- Re-fetches track metadata from server
- Updates queue with fresh data
- Retries playback as remote stream
- Notifies you of recovery
Graceful Degradation:
- If recovery fails completely
- For playback: informs you and advances to next track
- For preloading: fails silently (no interruption)
- Queue remains intact, playback continues
Download Deletion Handling
When you delete a download that's in the queue:
- Local file reference cleared immediately
- Track marked as needing remote stream
- Next playback fetches from server
- No errors or interruptions
- Queue position preserved
Rolling Cache System
Smart Download Window
Automatic management of offline content around your current position:
How It Works:
- Maintains a window of downloaded tracks around current playback
- Downloads upcoming tracks before you reach them
- Removes old downloads behind you to save space
- Configurable cache size (WiFi and cellular separate)
Cache Window:
[Old Downloads] [Current Track] [Future Downloads]
↓ ↓ ↓
Delete Zone Playing Now Addition Zone
Configurable Settings:
- Next Track Only: Cache just 1 upcoming track
- Numeric Limit: Cache N tracks ahead (e.g., 5, 10, 20)
- Unlimited: Cache entire remaining queue
Network Awareness:
- Respects cellular download settings
- Different limits for WiFi vs cellular
- Won't download on cellular if disabled
- Guards prevent excessive data usage
Repeat All Support:
- When approaching end of queue
- Wraps around to cache tracks from beginning
- Maintains full cache window even at queue end
- Seamless looping with offline content
Proactive Caching
Predictive Downloads
Llamafin anticipates your needs:
When Queue is Set:
- Analyses entire queue for missing downloads
- Calculates lookahead window based on settings
- Filters out tracks already downloaded
- Queues items for background download
Multiple Triggers:
- Queue Change: When you modify the queue
- Track Change: When advancing to next track
- Periodic Check: Every 30 seconds during playback
Guard Clauses:
- Caching must be enabled in settings
- Respects prefer_downloaded_media setting
- Checks cellular permissions
- Skips if all items already cached
Benefits:
- Seamless offline playback
- No manual download management
- Intelligent use of storage space
- Always prepared for network loss
Integration with Audio Engine
Clean Separation of Concerns
Player and Audio Engine work together:
Player Responsibilities:
- Queue management
- Shuffle and repeat logic
- Track selection and ordering
- Multi-device targeting
- State persistence
Audio Engine Responsibilities:
- Actual audio playback
- Web Audio API processing
- Stream management
- Gapless transitions
- Visualisation data
Communication Flow
Player → Audio Engine:
- "Play this track" (requestPlayback)
- "Pause/Resume/Stop"
- "Seek to position"
- "Set volume"
- "Preload these adjacent tracks"
Audio Engine → Player:
- "Playback started" (sync state)
- "Playback ended" (trigger next track)
- "Buffering status" (update UI)
- "Error occurred" (handle recovery)
synchronisation
When audio engine starts playing:
- Player validates track is in queue
- Updates current track reference if needed
- Preserves rich metadata (sonic analysis, etc.)
- Does NOT re-trigger playback pipeline
- Records offline playback statistics
Error Handling
Loading Errors
Empty Playlists:
- Detected before queue is set
- User notified with clear message
- Queue remains unchanged
- Loading state cleared
Missing User ID:
- Validated before API calls
- Prevents failed requests
- Informs user of authentication issue
- Suggests re-login
Network Failures:
- Retry logic for transient errors
- Graceful degradation to offline mode
- User notified of persistent failures
- Queue preserved for retry
Playback Errors
Stream Failures:
- Self-healing attempts recovery
- Falls back to remote stream if local missing
- Advances to next track if unrecoverable
- Maintains queue integrity
Device Errors:
- Audio context suspension handled
- Autoplay policy compliance
- User gesture requirements communicated
- Pending play requests retry automatically
Technical Specifications
| Specification | Value |
|---|---|
| Queue Size Limit | None (limited by memory) |
| Shuffle Algorithm | Fisher-Yates (Knuth) |
| Repeat Modes | 3 (off, one, all) |
| Previous Track Threshold | 5 seconds |
| Preload Debounce | 250ms |
| Rolling Cache Debounce (track) | 100ms |
| Rolling Cache Debounce (queue) | 150ms |
| Periodic Cache Check | Every 30 seconds |
| Crossfade Buffer | 2 tracks |
| Autoplay Trigger Threshold | ≤ 5 tracks remaining |
| Library Play All Limit | 500 tracks |
| Storage Keys | current_item, shuffle_status, repeat_status, playback_target |
| Playback Targets | local, Jellyfin session, Connect peer |