Audio Class
Audio class is designed to play audio sprites in a cross-platform compatible manner using HTML5 and the SwishSprite library.
Item Index
Methods
Methods
_onComplete
()
private
When either the sound or mute has finished
_onUpdate
-
p
Callback for the progress change update on the audio sprite
Parameters:
-
p
NumberThe progress from 0 to 1 of how much of the sprite we've completed
_playAudio
()
private
Internal method to play the audio
_playSilence
()
private
Start playing the silence when muted
_startSilence
()
private
Start the silence timer
_stopSilence
()
private
Stop the silence update
_updateSilence
-
elapsed
Progress update for the silence playing
Parameters:
-
elapsed
NumberThe number of ms elapsed since last update
destroy
()
public
Don't use after this, destroys singleton and releases all references
getAliases
-
includeSilence
Returns array of sound aliases in spritemap
Parameters:
-
includeSilence
BoolIf array should include silence alias
Returns:
sound aliases
getAudioSprite
()
cloudkid.SwishSprite
public
Get the instance of the SwishSprite
Returns:
getLength
-
alias
Returns length in seconds of named sprite sound
Parameters:
-
alias
StringThe sound alias
Returns:
The number of a seconds duration of a sprite
getMuted
()
Bool
public
Get the mute status of the audio
Returns:
If the audio is muted
hasAlias
-
alias
Returns if a sound alias is in the spritemap.
Parameters:
-
alias
StringThe sound alias to check for.
Returns:
true if the alias is in the spritemap, false otherwise.
init
-
dataURLorObject
-
onReady
Static constructor initializing Audio (and soundManager)
initialize
-
dataURLorObject
-
onReady
Audio controller constructor
isLooping
-
alias
Returns value of loop property for named sound
Parameters:
-
alias
BoolIf the alias is set to loop
isPlaying
()
Bool
public
Returns true if a sound is currently being played
Returns:
If the audio is current playing
isReady
-
alias
Check to make sure the audio is ready
Parameters:
-
alias
String*Optional alias to check for valid sprite sound
Returns:
If we can proceed with task
load
-
callback
Preload audio data for primary sprite, MUST be called by a click/touch event!!!
Parameters:
-
callback
FunctionThe callback function to call on load complete
mute
()
public
Set if the audio is muted
pause
()
public
Used if we need to pause the current sound and resume later
play
-
alias
-
onFinish
-
onStart
-
onUpdate
Play sound from sprite by Alias
Parameters:
-
alias
StringName of sound to play
-
onFinish
FunctionFunction called when the sound is done
-
onStart
FunctionFunction to be called when playback starts. This is called immediately, and is here to provide compatibility in usage with cloudkid.Sound.
-
onUpdate
FunctionFunction to return the current progress amount 0 to 1
resume
()
public
Used to resume sound paused with pause();
stop
-
doCallback
Used if we need to stop playing a sound and we don't need to resume from the current position
Parameters:
-
doCallback
BoolIf the callback should be called after stop
unmute
()
public
Set if the audio should turn off mute mode
Properties
_audioSprite
cloudkid.SwishSprite
private
Instance of the SwishSprite class
_data
Dictionary
private
Metadata regarding Primary Audio Sprite (URLs, Audio Timings)
_data
Bool
private
If the Audio instance has been destroyed
Default: false
_muted
Bool
private
If the sounds are muted
_paused
Bool
private
Set true only if paused by pause() used to determine validity of resume()
Default: false
soundLoaded
Bool
public
If the sound file is loaded