Module: engine/audio

Audio module is a simple wrapper of Howler.js.
For more details, see the Howler.js official site.

Source:

Examples

Load audio files

import loader from 'engine/loader';

// Add audio file with extensions, and give it an `id` for later use.
loader.add('bgm', 'bgm.ogg');
// You can
loader.add('bgm2', 'bgm2.webm|mp3');

// Note that ONLY files with extensions in `config.audio.use` will be
// properly loaded.

Play loaded sound file

import audio from 'engine/audio';

// Sound objects are just `Howl` instances
audio.sounds['bgm'].loop(true).play();

Requires

Members


<static> muted :boolean

Whether audio is muted.

Type:
  • boolean
Source:

<static> sounds :Object.<String, Howl>

Map of loaded audio files.

Type:
  • Object.<String, Howl>
Source:

Methods


<static> mute()

Mute.

Source:

<static> unmute()

Unmute.

Source:

<static> volume(v)

Get/set global audio volume.

Parameters:
Name Type Description
v number

Volume to set.

Source: