Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The same sound played in multiple succession on Safari can break sometimes #12

Open
HoofedEar opened this issue Aug 16, 2024 · 0 comments

Comments

@HoofedEar
Copy link
Contributor

So I noticed that if you call qx.playSound multiple times in a row on the same sound on Safari, the sound can end up breaking and either playing only a very tiny portion of the sound or no sound at all

A way that I found to fix this was to update qx.playSound to use cloneNode().play() instead:

export function playSound(sfx, volume = 1, loop = false) {
  qut.checkInstanceOf("sfx", sfx, HTMLAudioElement);
  sfx.currentTime = 0;
  sfx.volume = volume;
  sfx.loop = loop;
  sfx.cloneNode().play();
}

But I know this isn't ideal due to potential memory use, but so far it seems okay? I haven't noticed any performance at all using this method but I just wanted to create this issue here in case others have this problem too, and to maybe come up with a better solution

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

No branches or pull requests

1 participant