We need to preload and cache all the sounds, otherwise when we play a sound the first instance will play a second late. The Audio API has a 'preload' attribute that's designed to provide exactly this. However, when tested back in 2014, this did not work across all browsers. So we chose to play all sounds at minimum volume upon page load. At a volume of just 1%, this didn't used to be audible.
However, this preloading is now audible. Crank your volume up, and load any of the demo pages in Chrome (at least on a Mac). On page load, one can clearly hear the click and delete sounds. Despite the code, there's no way that this is 1% volume.
I think it's time that Blockly take another look at sounds and determine if there are better ways of preloading sounds in the majority of browsers. We will probably need to keep the hacky low-volume preload technique for IE, but at a minimum I'd expect that Chrome and FF should have proper preloading abilities. Also be aware that iOS can apparently only play one sound. This is a swamp of browser-specific gotchas.
Surfaced due to maribethb/blockly-games#171
We need to preload and cache all the sounds, otherwise when we play a sound the first instance will play a second late. The Audio API has a 'preload' attribute that's designed to provide exactly this. However, when tested back in 2014, this did not work across all browsers. So we chose to play all sounds at minimum volume upon page load. At a volume of just 1%, this didn't used to be audible.
However, this preloading is now audible. Crank your volume up, and load any of the demo pages in Chrome (at least on a Mac). On page load, one can clearly hear the click and delete sounds. Despite the code, there's no way that this is 1% volume.
I think it's time that Blockly take another look at sounds and determine if there are better ways of preloading sounds in the majority of browsers. We will probably need to keep the hacky low-volume preload technique for IE, but at a minimum I'd expect that Chrome and FF should have proper preloading abilities. Also be aware that iOS can apparently only play one sound. This is a swamp of browser-specific gotchas.
Surfaced due to maribethb/blockly-games#171