Skip to content

Prevent scrobbling and short playback artifacts when loading the app with previous track paused#867

Merged
dweymouth merged 6 commits intomainfrom
fix/no-playback-on-restore
Mar 5, 2026
Merged

Prevent scrobbling and short playback artifacts when loading the app with previous track paused#867
dweymouth merged 6 commits intomainfrom
fix/no-playback-on-restore

Conversation

@dweymouth
Copy link
Copy Markdown
Owner

Fixes #853

This pull request introduces a new mechanism for restoring the play queue so that, on app startup, the previously playing track is loaded in a paused state at the correct position—without immediately interacting with the audio backend (MPV). This avoids the previous workaround of momentarily playing, pausing, and seeking the track, which could cause audio artifacts. The implementation involves new command types, engine state handling, and careful management of UI and waveform updates.

Key changes:

Core Playback Engine and Command Handling

  • Added a new playback command (cmdLoadTrackPaused) and corresponding methods (LoadTrackPaused, loadTrackPaused) to support loading a track in a paused state at a specific position, updating engine state and UI/OS integrations without starting playback in the audio backend. [1] [2] [3] [4] [5]
  • Updated the NowPlaying and PlaybackStatus methods to correctly reflect the paused state when a track is loaded but not yet playing, ensuring UI consistency. [1] [2]
  • Modified the Continue method to begin playback from the paused state, handling scrobbling and track change logic correctly.

App Startup and Play Queue Restoration

  • Changed App.LoadSavedPlayQueue to use the new LoadTrackPaused method, eliminating the need for the previous workaround that could cause a brief playback artifact.

Waveform and UI Integration

  • Enhanced waveform image generation logic to ensure the waveform is updated appropriately when resuming from a paused-load state, and adjusted hooks to avoid redundant updates. [1] [2]

Other

  • Added missing package declaration in jukebox_mock.go for completeness.

These changes improve the reliability and user experience when restoring playback state on app startup, and provide a cleaner, more maintainable approach to handling paused track loading.

dweymouth and others added 3 commits February 21, 2026 09:40
Instead of play → pause → sleep → seek when restoring a paused session,
introduce loadTrackPaused which sets internal state and fires UI/OS
callbacks (song change, paused) without touching MPV. On Continue(),
detect pendingLoadPaused and start MPV playback from the saved position.

Also triggers waveform pre-generation for the paused track via the
onBeforeSongChange hook.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@dweymouth dweymouth changed the title Fix/no playback on restore Prevent scrobbling and short playback artifacts when loading the app with previous track paused Feb 27, 2026
@dweymouth dweymouth marked this pull request as ready for review February 27, 2026 16:52
@dweymouth dweymouth requested a review from Copilot February 27, 2026 16:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #853 by implementing a cleaner mechanism to restore playback state on app startup. Previously, the app would momentarily play, pause, and seek to restore a paused track, causing brief audio artifacts and unwanted scrobbling. The new LoadTrackPaused mechanism sets up the engine state (UI, OS integrations, waveform generation) without touching the MPV player, deferring actual playback initialization until the user presses Continue.

Changes:

  • Added LoadTrackPaused command and engine method to load a track in paused state without starting MPV playback
  • Modified NowPlaying() and PlaybackStatus() to correctly report state when a track is loaded but not yet playing
  • Enhanced waveform generation to handle tracks loaded in paused state at app startup
  • Simplified App.LoadSavedPlayQueue() to use the new mechanism, removing the play-pause-seek workaround

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
backend/playbackcommands.go Added cmdLoadTrackPaused command type and LoadTrackPaused method to command queue
backend/playbackengine.go Implemented loadTrackPaused method, updated state checks in NowPlaying/PlaybackStatus, and modified Continue/Stop/playTrackAt to handle pendingLoadPaused state
backend/playbackmanager.go Added LoadTrackPaused public API, isLoadTrackPaused helper, waveform handling for paused load state, and command processing
backend/app.go Replaced play-pause-seek workaround with LoadTrackPaused call for cleaner queue restoration
backend/mediaprovider/subsonic/jukebox_mock.go Added missing package declaration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dweymouth dweymouth merged commit a4dc148 into main Mar 5, 2026
10 of 11 checks passed
@dweymouth dweymouth deleted the fix/no-playback-on-restore branch March 5, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Starting Supersonic triggers short playback on the last paused track when 'Fade out on pause' is checked

2 participants