diff options
author | Simon Garrelou <simon.garrelou@gmail.com> | 2022-12-10 17:49:07 +0100 |
---|---|---|
committer | Simon Garrelou <simon.garrelou@gmail.com> | 2022-12-10 17:49:07 +0100 |
commit | aab665356867143cd471855f46e9fed617f4c3b9 (patch) | |
tree | 6e538a52ec8a40d13361406df5b8239f3b49cfba /src/keybinds.go | |
parent | e674c1245206ad055760235ae3d2156bebfcefe1 (diff) | |
download | termsonic-aab665356867143cd471855f46e9fed617f4c3b9.tar.gz termsonic-aab665356867143cd471855f46e9fed617f4c3b9.zip |
Play album/song next / end
Diffstat (limited to 'src/keybinds.go')
-rw-r--r-- | src/keybinds.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/keybinds.go b/src/keybinds.go index 2a9c16b..ffdf64a 100644 --- a/src/keybinds.go +++ b/src/keybinds.go | |||
@@ -54,6 +54,72 @@ func (a *app) setupMusicControlKeys(p *tview.Box) { | |||
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | if a.tv.GetFocus() == a.songsList { | ||
58 | if event.Rune() == 'e' { | ||
59 | // Add to end | ||
60 | sel := a.songsList.GetCurrentItem() | ||
61 | a.playQueue.Append(a.currentSongs[sel]) | ||
62 | |||
63 | a.updatePageQueue() | ||
64 | } else if event.Rune() == 'n' { | ||
65 | // Add next | ||
66 | sel := a.songsList.GetCurrentItem() | ||
67 | a.playQueue.Insert(1, a.currentSongs[sel]) | ||
68 | |||
69 | a.updatePageQueue() | ||
70 | } | ||
71 | } else if a.tv.GetFocus() == a.artistsTree { | ||
72 | if event.Rune() == 'e' { | ||
73 | // Add to end | ||
74 | sel := a.artistsTree.GetCurrentNode() | ||
75 | ref := sel.GetReference() | ||
76 | if ref == nil { | ||
77 | return nil | ||
78 | } | ||
79 | |||
80 | if ref.(selection).entryType != "album" { | ||
81 | return nil | ||
82 | } | ||
83 | |||
84 | id := ref.(selection).id | ||
85 | album, err := a.sub.GetMusicDirectory(id) | ||
86 | if err != nil { | ||
87 | a.alert("Error: %v", err) | ||
88 | return nil | ||
89 | } | ||
90 | |||
91 | for _, s := range album.Child { | ||
92 | a.playQueue.Append(s) | ||
93 | } | ||
94 | |||
95 | a.updatePageQueue() | ||
96 | } else if event.Rune() == 'n' { | ||
97 | // Add next | ||
98 | sel := a.artistsTree.GetCurrentNode() | ||
99 | ref := sel.GetReference() | ||
100 | if ref == nil { | ||
101 | return nil | ||
102 | } | ||
103 | |||
104 | if ref.(selection).entryType != "album" { | ||
105 | return nil | ||
106 | } | ||
107 | |||
108 | id := ref.(selection).id | ||
109 | album, err := a.sub.GetMusicDirectory(id) | ||
110 | if err != nil { | ||
111 | a.alert("Error: %v", err) | ||
112 | return nil | ||
113 | } | ||
114 | |||
115 | for i := len(album.Child) - 1; i >= 0; i-- { | ||
116 | a.playQueue.Insert(1, album.Child[i]) | ||
117 | } | ||
118 | |||
119 | a.updatePageQueue() | ||
120 | } | ||
121 | } | ||
122 | |||
57 | return event | 123 | return event |
58 | }) | 124 | }) |
59 | } | 125 | } |