gostations/radiomenu.go

30 lines
656 B
Go
Raw Normal View History

package main
2021-03-16 23:06:20 +00:00
import (
"fmt"
"github.com/dixonwille/wmenu/v5"
"os"
)
2021-03-16 23:06:20 +00:00
func Quit() {
os.Exit(0)
}
func RadioMenu(stations []stationRecord) *wmenu.Menu {
menu := wmenu.NewMenu("What is your choice?")
menu.Action(
func (opts []wmenu.Opt) error {
if opts[0].Text == "Quit"{Quit()}
val := fmt.Sprintf("%s",opts[0].Value)
fmt.Printf("Streaming: '" + opts[0].Text + "' at url - "+ val +"\n")
stdout, _ := subExecute(player(), options(), val)
fmt.Println(stdout)
menu.Run()
2021-03-16 23:06:20 +00:00
return nil
})
for _, station := range stations {
menu.Option(station.Name, station.Url, false, nil )
}
menu.Option("Quit", nil, true, nil)
return menu
}