Skip to content

Commit d9974df

Browse files
miguel-heygenclaude
andcommitted
fix(runtime): restore el.muted on natural end-of-playback path
The auto-pause-at-duration path in transportTick wasn't calling webAudio.stopAll(), leaving audio elements muted after natural playback end. Next WebAudio schedule would capture priorMuted=true, locking the mute through subsequent cycles. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 6d02056 commit d9974df

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎packages/core/src/runtime/init.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,8 @@ export function initSandboxRuntimeModular(): void {
17801780
// parent observes isPlaying=false at end and re-issues seek(0)+play()
17811781
// if its loop attribute is set.
17821782
if (clock.isPlaying() && clock.reachedEnd()) {
1783+
webAudio.stopAll();
1784+
clock.detachAudioSource();
17831785
clock.pause();
17841786
state.isPlaying = false;
17851787
const dur = clock.getDuration();

‎packages/core/src/runtime/webAudioTransport.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ describe("WebAudioTransport", () => {
6767
expect(mockEl.muted).toBe(true);
6868
});
6969

70+
it("stopAll called multiple times is safe (idempotent)", () => {
71+
const transport = new WebAudioTransport();
72+
transport.stopAll();
73+
transport.stopAll();
74+
expect(transport.isActive()).toBe(false);
75+
});
76+
7077
it("destroy clears buffer cache and nulls context", () => {
7178
const transport = new WebAudioTransport();
7279
transport.destroy();

0 commit comments

Comments
 (0)