Skip to content

Fix: Stop a paused instance for good - #294

Merged
zbdd merged 1 commit into
mainfrom
zbdd/stop-paused-instance
Oct 30, 2026
Merged

zbdd merged 1 commit into
mainfrom
zbdd/stop-paused-instance

Conversation

@zbdd

@zbdd zbdd commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

On WebAudio, stop() on a paused instance did nothing. Pausing drops the instance's source and stop() only acted when there was one, so the instance never emitted stop, stayed in the sound's instances and started playing again on the next resume. Thats every way of pausing (instance paused, mySound.pause(), pauseAll(), window blur), plus mySound.stop() and stopAll() while paused. HTML already stops paused instances.

Replaces #270, which gets the first resume right but leaves the instance live, so it comes back on the next pause and resume.

Fixes #258
Fixes #211

Changes

  • Setting paused on an instance after stopping it now throws on WebAudio, same as on HTML and as a stopped playing instance already did
  • New lifecycle tests on both backends. The WebAudio paused-path tests were red on main on the stop event, and with those checks removed, on the sound being audible again after resume

- WebAudio stop() did nothing while paused, since pausing nulls the source, so the instance never emitted stop, stayed in the sound's instances and played again on the next resume (#258)
- stop() now also acts when the instance is really paused, so Sound removes and pools it, on every pause path (instance, sound, pauseAll, window blur) and through Sound.stop and stopAll
- Lifecycle tests on both backends, checking the stop event, the instance count and silence on the analyser after resume
@zbdd
zbdd added this pull request to stack #296 October 30, 2026 00:42
@zbdd
zbdd merged commit 154e125 into main Oct 30, 2026
2 checks passed
@zbdd
zbdd deleted the zbdd/stop-paused-instance branch October 30, 2026 00:45
zbdd added a commit that referenced this pull request Nov 2, 2026
- WebAudio stop() did nothing while paused, since pausing nulls the source, so the instance never emitted stop, stayed in the sound's instances and played again on the next resume (#258)
- stop() now also acts when the instance is really paused, so Sound removes and pools it, on every pause path (instance, sound, pauseAll, window blur) and through Sound.stop and stopAll
- Lifecycle tests on both backends, checking the stop event, the instance count and silence on the analyser after resume

(cherry picked from commit 154e125)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling .stop() on a sound whilst the browser window is blurred does not actually stop the sound Sound Library not stopping paused Sounds on stop all

1 participant