Audio - globules-io/OGX.JS GitHub Wiki

Audio is an object that makes the link between stored audio files in Cache and Howler.js. All sounds added to the preload tag of app.json will be stored in OGX.JS's cache and can be accessed or played using Audio. All sounds are played via Howler.

Preload

OGX.JS provides a mechanism to preload and store sounds. Add references to the sounds to be preload in the app.json configuration such as

 {...,
      preload:{              
           "/snd":["click.mp3", "msg.mp3"]
           
      }, ...
 }

Play

To play a cached sound (_LOOP_ is false by default and _VOLUME_ set to 1).

 OGX.Audio.play(_ID_, _VOLUME_, _LOOP_);

A practical example

 OGX.Audio.play('click', 0.5);

Get

To retrieve a preloaded sound

 OGX.Audio.get(_ID_);