Constructor
new SoundSystem(musicIntervalSecondsopt)
Basic HTML5 Audio sound system
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
musicIntervalSeconds |
Number |
<optional> |
60 | Default is 60. |
Members
(static) _musicInterval
default is 60
(static) _trackPaused
_currentTrack
_soundIndex
_soundNames
_soundPlaying
_sounds
_soundTracks
_trackTimer
Methods
addMusic(soundLocation, vol, loop)
Add a music track to be played with playMusic. The first track you add would be at index 0 in _soundTracks, and additional calls are adding to _soundTracks.
Name | Type | Description |
---|---|---|
soundLocation |
String | The url location of the music track. |
vol |
Number | The volume of the track, 0 to 1. |
loop |
Boolean | Default is true |
addSound(soundLocation, name, vol, poolAmount)
Add a sound to be played with playSound
Name | Type | Description |
---|---|---|
soundLocation |
String | The Location of the sound to add. |
name |
String | A name for the sound |
vol |
Number | The volume of the sound 0 to 1. |
poolAmount |
Number | Amount to pre load, alows for faster one shots, default is 1. |
clearAllSounds()
Clear all sounds added with addSound
clearMusicTracks()
Clears all music added with addMusic.
playMusic(indexopt)
play a music track added with addMusic
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index |
Number |
<optional> |
0 | The index of the track to play, the first track added with addMusic is at index 0, the default is index 0. |
playSound(name, usePool)
play a sound added with addSound
Name | Type | Description |
---|---|---|
name |
String | The name of the sound to play, as defined during addSound |
usePool |
Boolean | If true, and you set a poolAmount during addSound, it will cycle through the preloaded pool, otherwise the sound will need to have finished first, before replay. If what you want is fast one shots of the same sound that potentially overlap, then use a pool of 2 or up to 10. |
stopMusic()
Stops the currrent music track from playing.