AngularJS Service for playing sounds using Howler.js
Members
(static) sounds
Stored list of sounds, with sound ID and Howler object.
Properties:
Name | Type | Description |
---|---|---|
sounds[].id |
string
|
A sound ID. |
sounds[].howl |
Object
|
A Howler sound object. |
- Source:
Methods
(static) find(id) → (nullable) {Object}
Find an object from module:soundService.sounds
.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
Returns:
- Type:
-
Object
Sound object if found.
(static) findAndCall(id, callback) → (nullable) {*}
Find an object from module:soundService.sounds
and execute a callback with it.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
callback |
function
|
A callback to run on the found audio object. |
Returns:
- Type:
-
*
The return value of the callback, if sound is found.
(static) playRandom(idArr, settingsopt)
Play a sound randomly from a list.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
idArr |
Array.<string>
|
An array of sound IDs. |
|
settings |
Object
|
<optional> |
Sound settings to use (see |
(static) play(id, settingsopt)
Play a specific sound.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string
|
A sound ID. |
|||||||||||||||||||||
settings |
Object
|
<optional> |
Sound settings to use.
|
(static) fade(id, settingsopt)
Fade a specific sound.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string
|
A sound ID. |
|||||||||||||||||||||
settings |
Object
|
<optional> |
Sound settings to use.
|
(static) isPlaying(id) → (nullable) {boolean}
Check if a sound is playing.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
Returns:
- Type:
-
boolean
(static) stop(id)
Stop a specific sound.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
(static) pause(id)
Pause a specific sound.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
(static) resume(id)
If given an id it will resume that sound if it is paused else it will resume all paused sounds.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
(static) muteAll(mute)
Mute all sounds.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
mute |
boolean
|
Whether or not to mute. |
(static) muteMultiple(arr, mute)
Mute all sounds in a list.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array.<string>
|
An array of sound IDs. |
mute |
boolean
|
Whether or not to mute. |
(static) mute(id, mute)
Mute a specific sound.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
mute |
boolean
|
Whether or not to mute. |
(static) load(options)
Load a sound.
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
|
(static) loadMultiple(data)
Load multiple sounds from a list.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<Object>
|
An array of objects to pass to |
(static) unload(id)
Unload a sound.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
(static) reset()
Unload all sounds and clear pause data.
- Source:
(static) setVolume(id, volume)
Set the volume for a specific sound.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
volume |
number
|
The sound volume (0.0-1.0). |
(static) getVolume(id) → (nullable) {number}
Get the volume for a specific sound.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
Returns:
- Type:
-
number
The sound volume (0.0-1.0).
(static) setRate(id, rate)
Set the rate for a specific sound, used for dynamic pitch shifting.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
A sound ID. |
rate |
number
|
The sound rate (0.5-4.0). |
(static) checkLoadCompletion() → {number}
Check load progress of all sounds.
- Source:
Returns:
- Type:
-
number
The percentage of sounds that are done loading (0.0-1.0).