Use URI instead of position to play songs in RecentlyPlayedView

This commit is contained in:
aditya-K2
2023-04-12 07:25:38 +05:30
parent 493297fec9
commit 086b6f7b5d
2 changed files with 17 additions and 2 deletions

View File

@@ -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,

View File

@@ -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
}