1
\$\begingroup\$

I am making an HTML5 game, which involves one audio being played multiple times at once.

I searched this issue up and found this: https://stackoverflow.com/questions/25654558/html5-js-play-same-sound-multiple-times-at-the-same-time

It seemed to help, except later a question came up:

If I do cloneNode(), will it copy the sound AND the currently loaded audio data, or will it have to reload the data?

Is there a better way to play multiple sounds while making sure no data needs to be reloaded?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Honestly I’d try it and see. \$\endgroup\$ Commented May 16, 2021 at 15:50
  • \$\begingroup\$ not helpful at all @bob \$\endgroup\$ Commented May 16, 2021 at 15:52
  • 1
    \$\begingroup\$ I’m not trying to be rude, I just mean what’s the harm in just trying it and seeing. You should be able to use the developer tools to debug and see whether it’s doing a reload (use the Network pane to see if the sound file is fetched a second time or not). Might be faster than waiting on an answer is all I was thinking. If that’s not the case then I retract my comment. \$\endgroup\$ Commented May 16, 2021 at 15:56
  • \$\begingroup\$ if I try I might have to rewrite my code \$\endgroup\$ Commented May 16, 2021 at 16:00
  • 1
    \$\begingroup\$ Yes, game development often includes rewriting code. I'd concur with bob that a great way to find the answer here is to construct a simple test and measure what you find. This will often be faster than waiting for a stranger to do the same thing and tell you what they found, or waiting even longer for a stranger who already knows the inner workings of cloneNode inside-out to happen to find your question. \$\endgroup\$ Commented May 16, 2021 at 16:19

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.