Well as I promised @PirateJC a Playground for audio sprites. I don’t know how to do PRs, I just use github as my website
So here is the basic PG - tested with Windows10 and Firefox. Playground
Basically three bits of code : 1. A basic scene, 2. The sound preparation code, 3 Button code and functionality.
The audio file has 6 sounds that are defined by the “soundArray” variable that includes the start point in the the file for each sound and the length of the sound .The “isPlaying” variable is the flag to stop sounds being played on top of each other by repeated clicks on the buttons. The top button plays the whole file (all six sounds), the second button creates a random number (0-5) then selects the start and length of that sound from the “soundArray” and plays it with the code line :
I have no idea what that first “0” is in the code or what its functionality is.
If you run it in Chrome (which I don’t use) you probably might have to include a call to this kind of code somewhere:
otherwise you might get an icon in top corner of the screen and the sounds may not play.
I’ve tried to explain the blocks of code as best I can. Not sure what the example code might be in the documentation. And I’m not a good coder - so maybe you can improve it
@PirateJC : So that is a start. Look forward to your comments and thoughts
Stay Safe, gryff
EDIT: This variation of the playground seems to work in Edge Browser without producing the “audio not playing” icon. No idea about Chrome, Safari or Android devices : Playground
Anyway @PirateJC change the code as you wish to improve the efficiency