I've been making web games for sometime now and I quickly noticed that once i use the .cloneNode(true)
to play back the same audio file multiple times to avoid re-downloading the file over and over each time I want to play an audio file, I loose control of things such as playback volume and playback rate, does anyone know how I can regain control of those parameters for each copy of the audio file?
I tried setting the parameters for the audio copies from the original file but no juice
In the HTML :
<audio src = "sight.wav" id="sight"/>
<button onclick="playSound()">Play some audio</audio>
In the Js
var get = new Function("id", "return document.getElementById(id)");
function playSound()
{
get(sight).volume = 0.30;
get(sight).playbackRate = 0.40;
get(sight).cloneNode(true).play();
};
Looks like valid code to me but like I said, no juice, the cloneNodes completely ignore the volume and playback settings and just play the normal audio. What should I do?