Added UpdatePlaylist Function
the UpdatePlaylist function updates the table `t` that has been passed to it and fills it with the current playlist. Also I have removed the addsong function which felt unneccesary and unused.
This commit is contained in:
parent
11eb7c35b6
commit
db9887c041
19
client.go
19
client.go
@ -19,6 +19,21 @@ func togglePlayBack(connection mpd.Client) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdatePlaylist(conn mpd.Client, t *tview.Table) {
|
||||||
|
_playlistAttr, _ := conn.PlaylistInfo(-1, -1)
|
||||||
|
|
||||||
|
t.Clear()
|
||||||
|
for i, j := range _playlistAttr {
|
||||||
|
if j["Title"] == "" || j["Artist"] == "" || j["Album"] == "" {
|
||||||
|
t.SetCell(i, 0, tview.NewTableCell(j["file"]))
|
||||||
|
} else {
|
||||||
|
t.SetCell(i, 0, tview.NewTableCell(j["Title"]))
|
||||||
|
t.SetCell(i, 1, tview.NewTableCell(j["Artist"]))
|
||||||
|
t.SetCell(i, 2, tview.NewTableCell(j["Album"]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func join(stringSlice []string) string {
|
func join(stringSlice []string) string {
|
||||||
var _s string = stringSlice[0]
|
var _s string = stringSlice[0]
|
||||||
for i := 1; i < len(stringSlice); i++ {
|
for i := 1; i < len(stringSlice); i++ {
|
||||||
@ -59,7 +74,3 @@ func Update(conn mpd.Client, f []FileNode, inputTable *tview.Table) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSong(conn mpd.Client, currentDirectoryStructure []string, currentCellContent string) {
|
|
||||||
conn.Add(join(currentDirectoryStructure) + "/" + currentCellContent)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user