Instantiate an audio engine:
this.audio = new SoundOnDemand();
To play a sound through the audio engine you need a channel - and you can define as many channels as you want.
Imagine channel as a tube you are shouting through. Tube can has its own properies affecting volume and effects.
this.sound = this.audio.channel("sound"); this.music = this.audio.channel("music");
Play sound through a channel.
This will look for
sounds/explosion.mp3 depending on your prefered audio format and format supported by the browser and play it as soon as possible.
That's it. For more advanced features dig the documentation.
Preloading a sound
You don't have to preload audio. It gets loaded automatically on the first use and played as soon as possible. Nevertheless if you cannot any delay you can preload the sound:
Loader returns a
Promise that is fulfilled as soon as the sound has been loaded.