Updated the Client Functions
Before the Update Function needed the currentDirectoryMap ( the Functionality was not confirmed ) as a parameter but now I have removed the currentDirectoryMap. Instead I have added totalPath ( going to rename this to `absolutePath` ) to the FileNode Struct which is added during the generation of the directory Tree whenever the selected field is called we can just pass the totalPath.
This commit is contained in:
parent
b6133cd1c9
commit
eecb86ed8f
49
client.go
49
client.go
@ -7,56 +7,59 @@ import (
|
|||||||
// "fmt"
|
// "fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var directoryMap map[string][]int = make(map[string][]int)
|
||||||
|
|
||||||
func togglePlayBack(connection mpd.Client) error {
|
func togglePlayBack(connection mpd.Client) error {
|
||||||
status, err := connection.Status()
|
status, err := connection.Status()
|
||||||
if(status["state"] == "play" && err == nil){
|
if status["state"] == "play" && err == nil {
|
||||||
connection.Pause(true)
|
connection.Pause(true)
|
||||||
} else if(status["state"] == "pause" && err == nil) {
|
} else if status["state"] == "pause" && err == nil {
|
||||||
connection.Play(-1)
|
connection.Play(-1)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
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++ {
|
||||||
if ( _s != ""){
|
if _s != "" {
|
||||||
_s += ( "/" + stringSlice[i])
|
_s += ("/" + stringSlice[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _s
|
return _s
|
||||||
}
|
}
|
||||||
|
|
||||||
func Update(conn mpd.Client, f []FileNode, currentDirectoryStructure [] string, inputTable *tview.Table) {
|
func Update(conn mpd.Client, f []FileNode, inputTable *tview.Table) {
|
||||||
ab := join(currentDirectoryStructure)
|
inputTable.Clear()
|
||||||
for i,j := range(f){
|
for i, j := range f {
|
||||||
if len(j.children) == 0 {
|
if len(j.children) == 0 {
|
||||||
a, err := conn.ListAllInfo(ab)
|
_songAttributes, err := conn.ListAllInfo(j.totalPath)
|
||||||
if err == nil {
|
if err == nil && _songAttributes[0]["Title"] != "" {
|
||||||
|
|
||||||
inputTable.SetCell(i, 0,
|
inputTable.SetCell(i, 0,
|
||||||
tview.NewTableCell("[#fbff00]" + a[0]["Title"]).
|
tview.NewTableCell("[#fbff00]"+_songAttributes[0]["Title"]).
|
||||||
SetAlign(tview.AlignLeft))
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
inputTable.SetCell(i, 1,
|
inputTable.SetCell(i, 1,
|
||||||
tview.NewTableCell("[#000000]" + a[0]["Artist"]).
|
tview.NewTableCell("[#fbff00]"+_songAttributes[0]["Artist"]).
|
||||||
SetAlign(tview.AlignLeft))
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
inputTable.SetCell(i, 2,
|
inputTable.SetCell(i, 2,
|
||||||
tview.NewTableCell("[#ff0030]" + a[0]["Album"]).
|
tview.NewTableCell("[#ff0030]"+_songAttributes[0]["Album"]).
|
||||||
SetAlign(tview.AlignLeft))
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
|
} else if _songAttributes[0]["Title"] == "" {
|
||||||
|
inputTable.SetCell(i, 0,
|
||||||
|
tview.NewTableCell("[blue]"+j.path).
|
||||||
|
SetAlign(tview.AlignLeft))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
inputTable.SetCell(i, 0,
|
inputTable.SetCell(i, 0,
|
||||||
tview.NewTableCell("[#fbff00::b]" + j.path).
|
tview.NewTableCell("[#fbff00::b]"+j.path).
|
||||||
SetAlign(tview.AlignLeft))
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSong(conn mpd.Client, currentDirectoryStructure [] string, currentCellContent string){
|
func addSong(conn mpd.Client, currentDirectoryStructure []string, currentCellContent string) {
|
||||||
conn.Add(join(currentDirectoryStructure) + "/" + currentCellContent)
|
conn.Add(join(currentDirectoryStructure) + "/" + currentCellContent)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user