Implement Next and Previous

This commit is contained in:
aditya-K2
2023-04-26 04:01:43 +05:30
parent 78b7d13756
commit 1fbb0fd897
4 changed files with 26 additions and 0 deletions

View File

@@ -94,6 +94,8 @@ $ gspt
1. `o` Open the Current Track's Album
1. `O` Open the Current Track's Artist
1. `ctrl-o` Open the Current Context (Album/Artist/Playlist)
1. `n` Play Next Song in Queue
1. `p` Play Previous Song in Queue
## Command-line Parameters

View File

@@ -34,6 +34,8 @@ var (
{R: ' '}: "toggle_playback",
{R: 'o'}: "open_current_track_album",
{R: 'O'}: "open_current_track_artist",
{R: 'n'}: "next",
{R: 'p'}: "previous",
{K: tcell.KeyCtrlO}: "open_current_context",
},
"playlist_nav": {

View File

@@ -61,3 +61,11 @@ func UriToID(uri spotify.URI) (spotify.ID, error) {
}
return spotify.ID(a[2]), nil
}
func Next() error {
return Client.Next(ctx())
}
func Previous() error {
return Client.Previous(ctx())
}

View File

@@ -235,6 +235,20 @@ func NewApplication() *tview.Application {
}
return nil
}, nil),
"next": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
if err := spt.Next(); err != nil {
SendNotification(err.Error())
return e
}
return nil
}, nil),
"previous": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
if err := spt.Previous(); err != nil {
SendNotification(err.Error())
return e
}
return nil
}, nil),
}
playlistNav.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
"play_entry": NewAction(playlistNav.PlaySelectEntry,