2020-01-22 22:54:55 +00:00
|
|
|
package main
|
|
|
|
|
2024-10-02 06:16:39 +00:00
|
|
|
import "github.com/gopxl/beep/v2/speaker"
|
2020-01-22 22:54:55 +00:00
|
|
|
|
|
|
|
type appConfig struct {
|
2021-05-02 06:34:23 +00:00
|
|
|
Input map[string][]string // Keybinds
|
|
|
|
Layout string
|
|
|
|
Volume int // Starting volume
|
2021-05-04 07:23:36 +00:00
|
|
|
Remember bool
|
2021-05-02 06:34:23 +00:00
|
|
|
Dir string
|
2021-09-02 20:06:27 +00:00
|
|
|
QueueFiles []*libraryEntry
|
2021-05-02 06:34:23 +00:00
|
|
|
QueuePlaying int
|
|
|
|
AudioPosition int
|
2020-01-22 22:54:55 +00:00
|
|
|
}
|
|
|
|
|
2020-01-28 16:10:01 +00:00
|
|
|
var config = &appConfig{
|
2021-05-04 07:23:36 +00:00
|
|
|
Layout: defaultLayout,
|
|
|
|
Volume: defaultVolume,
|
|
|
|
Remember: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
func clearAppState() {
|
|
|
|
config.Dir = ""
|
|
|
|
config.QueueFiles = nil
|
|
|
|
config.QueuePlaying = 0
|
|
|
|
config.AudioPosition = 0
|
2020-01-28 16:10:01 +00:00
|
|
|
}
|
2020-01-22 22:54:55 +00:00
|
|
|
|
2021-05-02 06:34:23 +00:00
|
|
|
func saveAppState() {
|
|
|
|
config.Dir = mainDirectory
|
|
|
|
config.QueueFiles = queueFiles
|
|
|
|
config.QueuePlaying = queuePlaying
|
|
|
|
speaker.Lock()
|
|
|
|
if playingStreamer == nil {
|
|
|
|
config.AudioPosition = 0
|
|
|
|
} else {
|
|
|
|
config.AudioPosition = playingStreamer.Position()
|
2020-01-22 22:54:55 +00:00
|
|
|
}
|
2021-05-02 06:34:23 +00:00
|
|
|
speaker.Unlock()
|
2020-01-22 22:54:55 +00:00
|
|
|
}
|