diff --git a/config/config.go b/config/config.go index 5ac7fac..947bf3c 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ var ( }, "search_view": { {K: tcell.KeyEnter}: "open_entry", + {K: tcell.KeyCtrlP}: "play_entry", }, "global": { {R: 'd'}: "choose_device", diff --git a/ui/app.go b/ui/app.go index b4fed4f..d9291f9 100644 --- a/ui/app.go +++ b/ui/app.go @@ -296,6 +296,10 @@ func NewApplication() *tview.Application { searchView.SelectEntry() return nil }, nil), + "play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { + searchView.PlaySelectEntry() + return nil + }, nil), })) artistsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{ "open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { diff --git a/ui/view_search.go b/ui/view_search.go index 097bbc7..2ad282c 100644 --- a/ui/view_search.go +++ b/ui/view_search.go @@ -133,6 +133,18 @@ func (a *SearchView) SelectEntry() { } } +func (a *SearchView) PlaySelectEntry() { + r, _ := Main.Table.GetSelection() + switch a.searchContent[r].Type { + case "album", "artist", "playlist": + { + if err := spt.PlayContext(&a.searchContent[r].URI); err != nil { + SendNotification(err.Error()) + } + } + } +} + func (a *SearchView) RefreshState() { if a.search != "" { results, err := spt.Search(a.search)