Skip to content

fix: prevent multiple simultaneous sound plays#83

Open
chabou wants to merge 1 commit into
remvze:mainfrom
chabou:fix/multiple-sound
Open

fix: prevent multiple simultaneous sound plays#83
chabou wants to merge 1 commit into
remvze:mainfrom
chabou:fix/multiple-sound

Conversation

@chabou

@chabou chabou commented Oct 18, 2025

Copy link
Copy Markdown

I was experimenting with some features and ran into an issue.
Currently, every sound is played multiple times simultaneously.

I added this log in the use-sound custom hook:

if (!sound.playing()) {
  const id = sound.play();
  console.log(`Playing ${id}`);
}

And with a single sound selected, this was the output:
image

After some digging, I found that sound.playing() is not reliable when sound.play() is called multiple times within a short timeframe.
This is because there’s a small delay before the sound state changes, due to asynchronous operations (queued actions).

The solution I found is to track this state manually on our side, to prevent additional sound.play() calls.

This bug is not noticeable to the user, but it makes things more complicated when trying to implement new sound-level features.

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.

1 participant