mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 22:08:04 -05:00
Implement Next and Previous
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
14
ui/app.go
14
ui/app.go
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user