mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 13:58:05 -05:00
Add repeat and shuffle
This commit is contained in:
@@ -47,6 +47,8 @@ var (
|
||||
{R: 'K'}: "decrease_image_height",
|
||||
{R: 'L'}: "increase_image_width",
|
||||
{K: tcell.KeyCtrlS}: "save_config",
|
||||
{R: 'z'}: "shuffle",
|
||||
{R: 'r'}: "repeat",
|
||||
},
|
||||
},
|
||||
"playlist_nav": {
|
||||
|
||||
25
spt/play.go
25
spt/play.go
@@ -69,3 +69,28 @@ func Next() error {
|
||||
func Previous() error {
|
||||
return Client.Previous(ctx())
|
||||
}
|
||||
|
||||
func Shuffle() error {
|
||||
s, err := GetPlayerState()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return Client.Shuffle(ctx(), !s.ShuffleState)
|
||||
}
|
||||
|
||||
func Repeat() error {
|
||||
s, err := GetPlayerState()
|
||||
next := map[string]string{
|
||||
"context": "track",
|
||||
"track": "off",
|
||||
"off": "context",
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return Client.Repeat(ctx(), next[s.RepeatState])
|
||||
}
|
||||
|
||||
12
ui/app.go
12
ui/app.go
@@ -128,6 +128,18 @@ func NewApplication() *tview.Application {
|
||||
|
||||
// Define Actions
|
||||
globalActions := map[string]*Action{
|
||||
"shuffle": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
if err := spt.Shuffle(); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
return nil
|
||||
}, progressBar),
|
||||
"repeat": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
if err := spt.Repeat(); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
return nil
|
||||
}, progressBar),
|
||||
"save_config": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
msg := "Config Saved Successfully!"
|
||||
if err := config.WriteConfig(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user