feat(lotus-audio-inject): one soundboard clip at a time (replace mode)
playInjectedClip now stops any in-flight clip (via the existing idempotent cleanup) before starting a new one, so rapid taps replace rather than overlap/stack — no track leak. The host also debounces the button. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
940d71da92
commit
0aef1c5fe2
@@ -101,6 +101,13 @@ async function playInjectedClip(
|
||||
return;
|
||||
}
|
||||
|
||||
// Max ONE clip at a time (replace mode): stop any in-flight clip before
|
||||
// starting a new one, so clips can't overlap or be spammed. Runs
|
||||
// synchronously before the first await, and each cleanup() is idempotent and
|
||||
// removes itself from activeClips (so no track leak). The host also debounces
|
||||
// the button; together they cover the brief fetch window.
|
||||
for (const abort of [...activeClips]) abort();
|
||||
|
||||
const resp = await fetch(url, { credentials: "omit", mode: "cors" });
|
||||
if (!resp.ok) throw new Error(`fetch ${url} -> ${resp.status}`);
|
||||
const arrayBuffer = await resp.arrayBuffer();
|
||||
|
||||
Reference in New Issue
Block a user