feat: Adding next song
This commit is contained in:
@@ -22,7 +22,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
comandosPermitidos := []string{"play", "pause", "info"}
|
||||
comandosPermitidos := []string{"play", "pause", "info", "next"}
|
||||
var comando string
|
||||
if slices.Contains(comandosPermitidos, os.Args[1]) {
|
||||
comando = os.Args[1]
|
||||
|
||||
@@ -38,6 +38,8 @@ func menuController(conn net.Conn) {
|
||||
out = pauseSong(conn)
|
||||
case "info":
|
||||
out = infoSong(conn)
|
||||
case "next":
|
||||
out = nextSong(conn)
|
||||
}
|
||||
_, err = conn.Write([]byte(out))
|
||||
if err != nil {
|
||||
@@ -71,3 +73,12 @@ func infoSong(conn net.Conn) string {
|
||||
}
|
||||
return string(output)
|
||||
}
|
||||
|
||||
func nextSong(conn net.Conn) string {
|
||||
cmd := exec.Command("mpc", "next")
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println("Error al reproducir siguiente cancion", err)
|
||||
}
|
||||
return string(output)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user