Handle muting streams
This commit is contained in:
parent
bfd0bb866a
commit
9926248109
@ -154,18 +154,18 @@ func (s *PulseaudioInput) SetMixer(stream string, volume *inputs.InputMixer) err
|
||||
|
||||
for _, input := range sinkinputs {
|
||||
if strconv.FormatInt(input.Index, 10) == stream {
|
||||
cmd := exec.Command("pactl", "set-sink-input-volume", stream, strconv.FormatUint(uint64(volume.Volume), 10))
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to set volume: %w", err)
|
||||
}
|
||||
|
||||
if input.Mute != volume.Mute {
|
||||
cmd := exec.Command("pactl", "set-sink-input-mute", stream, "toggle")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to change mute state: %w", err)
|
||||
}
|
||||
} else {
|
||||
cmd := exec.Command("pactl", "set-sink-input-volume", stream, strconv.FormatUint(uint64(volume.Volume), 10))
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to set volume: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -11,6 +11,9 @@
|
||||
altering_mixer = null;
|
||||
}, 450);
|
||||
}
|
||||
async function muteMixer(input, streamid, mute) {
|
||||
fetch(`api/inputs/${input.name}/streams/${streamid}/volume`, {headers: {'Accept': 'application/json'}, method: 'POST', body: JSON.stringify({'mute': mute !== undefined ? mute : input.mixer[streamid].mute})}).then(() => inputs.refresh());
|
||||
}
|
||||
</script>
|
||||
|
||||
<ul class="list-group list-group-flush">
|
||||
@ -31,23 +34,33 @@
|
||||
<label for={'input' + iid + 'stream' + idstream} class="form-label d-inline">{title}</label>
|
||||
<span class="text-muted">({input.name})</span>
|
||||
</div>
|
||||
{#if input.controlable}
|
||||
<div>
|
||||
<div class="d-flex align-items-center">
|
||||
{#if input.mixable && input.mixer[idstream]}
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
class="btn btn-sm ms-1"
|
||||
class:btn-primary={input.mixer[idstream].mute}
|
||||
class:btn-secondary={!input.mixer[idstream].mute}
|
||||
on:click={() => {muteMixer(input, idstream, !input.mixer[idstream].mute);}}
|
||||
>
|
||||
<i class="bi bi-volume-mute-fill"></i>
|
||||
</button>
|
||||
{/if}
|
||||
{#if input.controlable}
|
||||
<button
|
||||
class="btn btn-sm btn-primary ms-1"
|
||||
on:click={() => input.playpause(idstream)}
|
||||
>
|
||||
<i class="bi bi-pause"></i>
|
||||
</button>
|
||||
</div>
|
||||
{:else if input.mixable && input.mixer[idstream]}
|
||||
<div
|
||||
class="badge bg-primary"
|
||||
title={input.mixer[idstream].volume_percent}
|
||||
>
|
||||
{input.mixer[idstream].volume_db}
|
||||
</div>
|
||||
{/if}
|
||||
{:else if input.mixable && input.mixer[idstream]}
|
||||
<div
|
||||
class="badge bg-primary ms-1"
|
||||
title={input.mixer[idstream].volume_percent}
|
||||
>
|
||||
{input.mixer[idstream].volume_db}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if input.mixable && input.mixer[idstream]}
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user