mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-07 21:13:50 -05:00
Implement QueueSongsVisual for album_view
This commit is contained in:
@@ -104,6 +104,7 @@ var (
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
},
|
||||
"nav_menu": {},
|
||||
|
||||
@@ -370,6 +370,7 @@ func NewApplication() *tview.Application {
|
||||
// Visual Actions
|
||||
albumView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||
"add_to_playlist": albumView.AddToPlaylistVisual,
|
||||
"queue_entry": albumView.QueueSongsVisual,
|
||||
})
|
||||
recentlyPlayedView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||
"add_to_playlist": recentlyPlayedView.AddToPlaylistVisual,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aditya-K2/gspt/spt"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/zmb3/spotify/v2"
|
||||
@@ -72,6 +74,22 @@ func (a *AlbumView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcel
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AlbumView) QueueSongsVisual(start, end int, e *tcell.EventKey) *tcell.EventKey {
|
||||
tracks := (*(*a.currentFullAlbum).Tracks)[start : end+1]
|
||||
msg := SendNotificationWithChan(fmt.Sprintf("Queueing %d tracks...", len(tracks)))
|
||||
go func() {
|
||||
err := spt.QueueTracks(Map(tracks,
|
||||
func(s spotify.SimpleTrack) spotify.ID {
|
||||
return s.ID
|
||||
})...)
|
||||
if err != nil {
|
||||
msg <- err.Error()
|
||||
}
|
||||
msg <- fmt.Sprintf("Queued %d tracks!", len(tracks))
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AlbumView) OpenEntry() {
|
||||
r, _ := Main.GetSelection()
|
||||
if err := spt.PlaySongWithContext(a.currentFullAlbum.URI, r); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user