Give Sound the whole story, and keep the buttons inside the card
Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
@@ -54,9 +54,16 @@ function muted(application) {
|
||||
return nodes.length > 0 && nodes.every(node => node.audio.muted === true);
|
||||
}
|
||||
|
||||
function setVolume(application, value) {
|
||||
const next = Math.max(0, Math.min(1, Number(value)));
|
||||
if (!Number.isFinite(next)) return false;
|
||||
// `max` is the ceiling the value is clamped to, defaulting to 1. It is a
|
||||
// parameter rather than a constant so over-amplification (1.5) stays a caller's
|
||||
// decision: this file is deliberately free of any Settings dependency so it can
|
||||
// be reasoned about -- and tested -- as plain JavaScript.
|
||||
function setVolume(application, value, max) {
|
||||
const requested = Number(value);
|
||||
if (!Number.isFinite(requested)) return false;
|
||||
const ceiling = Number(max);
|
||||
const bound = Number.isFinite(ceiling) && ceiling > 0 ? ceiling : 1;
|
||||
const next = Math.max(0, Math.min(bound, requested));
|
||||
const nodes = audioNodes(application);
|
||||
for (const node of nodes) {
|
||||
node.audio.muted = false;
|
||||
|
||||
Reference in New Issue
Block a user