SoundProvider

SoundProvider

This provider (singleton) takes care of loading and controlling sounds

Constructor

new SoundProvider()

Source:

Extends

Members

(private) backgroundSoundTimeout_ :number

Description:
  • Timeout ID for the delayed playback of the generic platform sound.

Source:

Timeout ID for the delayed playback of the generic platform sound.

Type:
  • number

enableBackgroundSound

Description:
  • Setter For playing a loop sound instead of a random delayed generic platform sound change the variable SOUND_MODE to loop in app/views/index.php // var SOUND_MODE = 'loop';

Source:

Setter For playing a loop sound instead of a random delayed generic platform sound change the variable SOUND_MODE to loop in app/views/index.php // var SOUND_MODE = 'loop';

enableBackgroundSound

Description:
  • Getter

Source:

Getter

(private) enableBackgroundSound_ :boolean

Description:
  • Is the playback of background sound enabled

Source:

Is the playback of background sound enabled

Type:
  • boolean

(private) firstBackgroundPlayback_ :boolean

Description:
  • Was started the first generic platform background sound

Source:

Was started the first generic platform background sound

Type:
  • boolean

(protected) muteExeptions_ :Array.<string>

Description:
  • Defines a list of sound keys (file names without the extension) which should be excluded from muting.

Source:
Overrides:

Defines a list of sound keys (file names without the extension) which should be excluded from muting.

Type:
  • Array.<string>

muted

Description:
  • Setter

Source:
Overrides:

Setter

(protected) muted_ :boolean

Description:
  • Defines if all handled sounds should be muted.

Source:
Overrides:

Defines if all handled sounds should be muted.

Type:
  • boolean

soundAssetPath

Description:
  • Setter

Source:
Overrides:

Setter

(protected) soundAssetPath_ :string

Description:
  • Defines the default relative sound asset path.

Source:
Overrides:

Defines the default relative sound asset path.

Type:
  • string

soundAssetUrl

Description:
  • Getter

Source:
Overrides:

Getter

(protected) soundAssetUrl_ :string

Description:
Source:
Overrides:

It is an absolute asset URL if the variable window.ASSET_URL is set, otherwise it is the relative HowlerSoundProvider#soundAssetPath_.

Type:
  • string

(protected) soundLoadPromise_ :Map.<string, Promise>

Description:
  • List of stored loading promises, where key ist the file name (without the extension).

Source:
Overrides:

List of stored loading promises, where key ist the file name (without the extension).

Type:
  • Map.<string, Promise>

(protected) sounds_ :Map.<string, HowlSound>

Description:
  • All loaded sounds will be saved in this list. The key is the sound file name (without the extension).

Source:
Overrides:

All loaded sounds will be saved in this list. The key is the sound file name (without the extension).

Type:

Methods

addMuteExeptions(keyOrArrayOfKeys)

Description:
  • Adds a sound key or a list of sound keys (file names without the extension) to the exclude list for muting.

Source:
Overrides:
Parameters:
Name Type Description
keyOrArrayOfKeys string | Array.<string>

Key is a file name without the extension

changeVolume(key, volume)

Description:
  • Change the volume of the sound with the given key (file name without the extension)

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

volume number

fadeSound(key, from, to, duration, loopopt, preventStopopt) → {Promise}

Description:
  • Fade the volume of the sound with the given key (file name without the extension) Returns a promise that is fulfilled when the sound fade was completed.

Source:
Overrides:
Parameters:
Name Type Attributes Default Description
key string

Sound file name without the extension

from number

Starting volume

to number

Starting volume

duration number

in seconds

loop boolean <optional>
false

after fading

preventStop boolean <optional>
false
Returns:
Type
Promise

getActiveInstanceKeys() → {Array.<string>}

Description:
  • Gets a list of sound keys (filenames without extension) where the sound is currently playing.

Source:
Overrides:
Returns:
Type
Array.<string>

getSoundByKey(key) → {HowlSound}

Description:
  • Gets the sound instance of a sound with the given key (file name without the extension).

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

Returns:
Type
HowlSound

getSoundDuration(key) → {number}

Description:
  • Gets the duration of a sound with the given key (file name without the extension).

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

Returns:
Type
number

(protected) isJsonFile_(path) → {boolean}

Description:
  • Check if the specified file path represents a json file.

Source:
Overrides:
Parameters:
Name Type Description
path string
Returns:
Type
boolean

isSoundPlaying(key) → {boolean}

Description:
  • Checks if a sound with the given key (file name without the extension) is playing.

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

Returns:
Type
boolean

load(sounds, preventCDNServiceopt) → {Promise}

Description:
  • Loads a sound or a list of sounds and store them in the HowlerSoundProvider#sound_ list. It is also possible to use a manifest.json to load the sounds. Returns a promise that is fulfilled when the source is loaded and saved in the HowlerSoundProvider#soundLoadPromise_ list.

Source:
Overrides:
Parameters:
Name Type Attributes Default Description
sounds Array.<string> | string

File path(s).

preventCDNService boolean <optional>
false

Prevent loading over a cdn url, which is part of HowlerSoundProvider#soundAssetUrl_. Loading path will be relative stating with HowlerSoundProvider#soundAssetPath_.

Returns:
Type
Promise

muteSoundByKey(key, value)

Description:
  • Mute or unmute a sound with the given key (file name without the extension).

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

value boolean

pauseSound(key, enable) → {Promise}

Description:
  • Pause or unpause a sound with the given key (file name without the extension).

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

enable boolean
Returns:
Type
Promise

(private) playBackgroundSound_()

Description:
  • Starts the random delayed playback of the generic platform background sound. Sound is played the first time after 3 seconds and then again after a pause of 30 - 60 seconds

Source:

playSound(key, volumeopt, loopopt) → {Promise}

Description:
  • Play a sound with the given key (file name without the extension) Returns a promise that is fulfilled when the sound was played.

Source:
Overrides:
Parameters:
Name Type Attributes Default Description
key string

Sound file name without the extension

volume number <optional>
1
loop boolean <optional>
false
Returns:
Type
Promise

stopAllSounds()

Description:
  • Stop all sounds

Source:
Overrides:

stopSound(key) → {Promise}

Description:
  • Stop a sound with the given key (file name without the extension). If the sound was playing its play promise will be rejected.

Source:
Overrides:
Parameters:
Name Type Description
key string

Sound file name without the extension

Returns:
Type
Promise