diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -42,7 +42,7 @@ type State struct { Theme *material.Theme IsPlaying bool Title string - UrlSelector widget.Enum + SourceSelector widget.Enum PlayPauseButton widget.Clickable PlayerContext context.Context PlayerCancel context.CancelFunc @@ -105,7 +105,7 @@ func (ui *Ui) HandleInputs(gtx layout.Context) { if ui.State.IsPlaying { ui.State.PlayerCancel() } else { - if ui.State.UrlSelector.Value == "" { + if ui.State.SourceSelector.Value == "" { log.Println("A URL has to be selected.") } else { ui.State.PlayerContext, ui.State.PlayerCancel = context.WithCancel(context.Background()) @@ -115,7 +115,7 @@ func (ui *Ui) HandleInputs(gtx layout.Context) { targets = append(targets, net.HardwareAddr(entry.Mac)) } } - go play(ui.State.PlayerContext, ui.State.UrlSelector.Value, targets, ui) + go play(ui.State.PlayerContext, ui.State.SourceSelector.Value, targets, ui) } } } @@ -149,9 +149,12 @@ func (ui *Ui) Layout(gtx layout.Context) layout.Dimensions { layout.Rigid(layout.Spacer{Height: unit.Dp(25)}.Layout), } + entries = append(entries, layout.Rigid(material.RadioButton( + ui.State.Theme, &ui.State.SourceSelector, + "PipeWire", "This device (experimental)").Layout)) for _, url := range ui.State.Config.URLs { entries = append(entries, layout.Rigid(material.RadioButton( - ui.State.Theme, &ui.State.UrlSelector, + ui.State.Theme, &ui.State.SourceSelector, url.Url, url.Name).Layout)) } @@ -174,7 +177,12 @@ func play(ctx context.Context, url string, targets []net.HardwareAddr, ui *Ui) { setPlayingState(true) defer setPlayingState(false) - err := soundbox.StreamURLContext(ctx, url, targets) + var err error + if url == "PipeWire" { + err = soundbox.StreamPipewireContext(ctx, targets) + } else { + err = soundbox.StreamURLContext(ctx, url, targets) + } if err != nil { log.Println(err) } |