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 {
|
for _, input := range sinkinputs {
|
||||||
if strconv.FormatInt(input.Index, 10) == stream {
|
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 {
|
if input.Mute != volume.Mute {
|
||||||
cmd := exec.Command("pactl", "set-sink-input-mute", stream, "toggle")
|
cmd := exec.Command("pactl", "set-sink-input-mute", stream, "toggle")
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to change mute state: %w", err)
|
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
|
return nil
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
altering_mixer = null;
|
altering_mixer = null;
|
||||||
}, 450);
|
}, 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>
|
</script>
|
||||||
|
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
@ -31,24 +34,34 @@
|
|||||||
<label for={'input' + iid + 'stream' + idstream} class="form-label d-inline">{title}</label>
|
<label for={'input' + iid + 'stream' + idstream} class="form-label d-inline">{title}</label>
|
||||||
<span class="text-muted">({input.name})</span>
|
<span class="text-muted">({input.name})</span>
|
||||||
</div>
|
</div>
|
||||||
{#if input.controlable}
|
<div class="d-flex align-items-center">
|
||||||
<div>
|
{#if input.mixable && input.mixer[idstream]}
|
||||||
<button
|
<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)}
|
on:click={() => input.playpause(idstream)}
|
||||||
>
|
>
|
||||||
<i class="bi bi-pause"></i>
|
<i class="bi bi-pause"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
{:else if input.mixable && input.mixer[idstream]}
|
{:else if input.mixable && input.mixer[idstream]}
|
||||||
<div
|
<div
|
||||||
class="badge bg-primary"
|
class="badge bg-primary ms-1"
|
||||||
title={input.mixer[idstream].volume_percent}
|
title={input.mixer[idstream].volume_percent}
|
||||||
>
|
>
|
||||||
{input.mixer[idstream].volume_db}
|
{input.mixer[idstream].volume_db}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{#if input.mixable && input.mixer[idstream]}
|
{#if input.mixable && input.mixer[idstream]}
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
|
Loading…
Reference in New Issue
Block a user