fix: defer MPV playback start until user unpauses on session restore

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 <noreply@anthropic.com>
This commit is contained in:
Drew Weymouth
2026-02-21 09:40:59 -08:00
co-authored by Claude Sonnet 4.6
parent ce3ae4f15a
commit dba540861f
5 changed files with 80 additions and 6 deletions
+13
View File
@@ -30,6 +30,8 @@ const (
cmdLoadRadioStation // arg: *mediaprovider.RadioStation, arg2: InsertQueueMode
cmdForceRestartPlayback
cmdLoadTrackPaused // arg: int (idx), arg2: float64 (startTime)
)
type playbackCommand struct {
@@ -185,6 +187,17 @@ func (c *playbackCommandQueue) SetQueueState(tracks []*mediaprovider.Track, queu
c.cmdAvailable.Signal()
}
func (c *playbackCommandQueue) LoadTrackPaused(idx int, startTime float64) {
c.mutex.Lock()
c.queue = append(c.queue, playbackCommand{
Type: cmdLoadTrackPaused,
Arg: idx,
Arg2: startTime,
})
c.mutex.Unlock()
c.cmdAvailable.Signal()
}
func (c *playbackCommandQueue) addCommand(command playbackCommand) {
c.mutex.Lock()
c.queue = append(c.queue, command)