diff --git a/backend/app.go b/backend/app.go index d98fbf7..f57d3fd 100644 --- a/backend/app.go +++ b/backend/app.go @@ -317,7 +317,21 @@ func (a *App) LoadSavedPlayQueue() error { if err != nil { return err } - return a.PlaybackManager.LoadTracks(queue.Tracks, false, false) + if len(queue.Tracks) == 0 { + return nil + } + + if err := a.PlaybackManager.LoadTracks(queue.Tracks, false, false); err != nil { + return err + } + if queue.TrackIndex >= 0 { + // TODO: This isn't ideal but doesn't seem to cause an audible play-for-a-split-second artifact + a.PlaybackManager.PlayTrackAt(queue.TrackIndex) + a.PlaybackManager.Pause() + time.Sleep(50 * time.Millisecond) // MPV seek fails if run immediately after + a.PlaybackManager.SeekSeconds(queue.TimePos) + } + return nil } func (a *App) SaveConfigFile() { diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 7781f67..54d6797 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -142,9 +142,11 @@ func (m *MainWindow) RunOnServerConnectedTasks(app *backend.App, displayAppName m.BottomPanel.NowPlaying.DisableRating = !canRate if app.Config.Application.SavePlayQueue { - if err := app.LoadSavedPlayQueue(); err != nil { - log.Printf("failed to load saved play queue: %s", err.Error()) - } + go func() { + if err := app.LoadSavedPlayQueue(); err != nil { + log.Printf("failed to load saved play queue: %s", err.Error()) + } + }() } // check if launching new version, else if found available update on startup