mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Use URI instead of position to play songs in RecentlyPlayedView
This commit is contained in:
@@ -21,6 +21,13 @@ func PlaySongWithContext(context *spotify.URI, position int) error {
|
||||
})
|
||||
}
|
||||
|
||||
func PlaySongWithContextURI(context, uri *spotify.URI) error {
|
||||
return play(&spotify.PlayOptions{
|
||||
PlaybackContext: context,
|
||||
PlaybackOffset: &spotify.PlaybackOffset{URI: *uri},
|
||||
})
|
||||
}
|
||||
|
||||
func PlayContext(context *spotify.URI) error {
|
||||
return play(&spotify.PlayOptions{
|
||||
PlaybackContext: context,
|
||||
|
||||
@@ -61,9 +61,17 @@ func (re *RecentlyPlayedView) ExternalInputCapture() func(e *tcell.EventKey) *tc
|
||||
return func(e *tcell.EventKey) *tcell.EventKey {
|
||||
if e.Key() == tcell.KeyEnter {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
if err := spt.PlaySong(re.recentlyPlayed[r].Track.URI); err != nil {
|
||||
SendNotification(err.Error())
|
||||
contextUri := re.recentlyPlayed[r].PlaybackContext.URI
|
||||
if string(contextUri) != "" {
|
||||
if err := spt.PlaySongWithContextURI(&re.recentlyPlayed[r].PlaybackContext.URI, &re.recentlyPlayed[r].Track.URI); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
} else {
|
||||
if err := spt.PlaySong(re.recentlyPlayed[r].Track.URI); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user