Audio - globules-io/OGX.JS GitHub Wiki
Audio
is an object that makes the link between stored audio files in Cache andHowler.js
. All sounds added to thepreload
tag ofapp.json
will be stored in OGX.JS's cache and can be accessed or played usingAudio
. 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_
isfalse
by default and_VOLUME_
set to1
).
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_);