save and load play queue on exit/startup (partial impl)
This commit is contained in:
@@ -25,6 +25,7 @@ const (
|
||||
sessionDir = "session"
|
||||
sessionLockFile = ".lock"
|
||||
sessionActivateFile = ".activate"
|
||||
savedQueueFile = "saved_queue.json"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -300,6 +301,9 @@ func (a *App) DeleteServerCacheDir(serverID uuid.UUID) error {
|
||||
func (a *App) Shutdown() {
|
||||
a.MPRISHandler.Shutdown()
|
||||
a.PlaybackManager.DisableCallbacks()
|
||||
if a.Config.Application.SavePlayQueue {
|
||||
SavePlayQueue(a.ServerManager.ServerID.String(), a.PlaybackManager, configdir.LocalConfig(a.appName, savedQueueFile))
|
||||
}
|
||||
a.PlaybackManager.Stop() // will trigger scrobble check
|
||||
a.Config.LocalPlayback.Volume = a.LocalPlayer.GetVolume()
|
||||
a.cancel()
|
||||
@@ -308,6 +312,14 @@ func (a *App) Shutdown() {
|
||||
os.RemoveAll(configdir.LocalConfig(a.appName, sessionDir))
|
||||
}
|
||||
|
||||
func (a *App) LoadSavedPlayQueue() error {
|
||||
queue, err := LoadPlayQueue(configdir.LocalConfig(a.appName, savedQueueFile), a.ServerManager)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return a.PlaybackManager.LoadTracks(queue.Tracks, false, false)
|
||||
}
|
||||
|
||||
func (a *App) SaveConfigFile() {
|
||||
a.Config.WriteConfigFile(a.configPath())
|
||||
a.lastWrittenCfg = *a.Config
|
||||
|
||||
Reference in New Issue
Block a user