API Documentation for: 2.1.0
Show:

Audio Class

Defined in: Audio:13
Namespace: cloudkid

Audio class is designed to play audio sprites in a cross-platform compatible manner using HTML5 and the SwishSprite library.

Methods

_onComplete

() private

Defined in _onComplete:581

When either the sound or mute has finished

_onUpdate

(
  • p
)
private

Defined in _onUpdate:568

Callback for the progress change update on the audio sprite

Parameters:

  • p Number

    The progress from 0 to 1 of how much of the sprite we've completed

_playAudio

() private

Defined in _playAudio:549

Internal method to play the audio

_playSilence

() private

Defined in _playSilence:486

Start playing the silence when muted

_startSilence

() private

Defined in _startSilence:504

Start the silence timer

_stopSilence

() private

Defined in _stopSilence:517

Stop the silence update

_updateSilence

(
  • elapsed
)
private

Defined in _updateSilence:527

Progress update for the silence playing

Parameters:

  • elapsed Number

    The number of ms elapsed since last update

destroy

() public

Defined in destroy:761

Don't use after this, destroys singleton and releases all references

getAliases

(
  • includeSilence
)
Array public

Defined in getAliases:732

Returns array of sound aliases in spritemap

Parameters:

  • includeSilence Bool

    If array should include silence alias

Returns:

Array:

sound aliases

getAudioSprite

() cloudkid.SwishSprite public

Defined in getAudioSprite:305

Get the instance of the SwishSprite

Returns:

cloudkid.SwishSprite:

getLength

(
  • alias
)
Number public

Defined in getLength:646

Returns length in seconds of named sprite sound

Parameters:

  • alias String

    The sound alias

Returns:

Number:

The number of a seconds duration of a sprite

getMuted

() Bool public

Defined in getMuted:696

Get the mute status of the audio

Returns:

Bool:

If the audio is muted

hasAlias

(
  • alias
)
Bool public

Defined in hasAlias:720

Returns if a sound alias is in the spritemap.

Parameters:

  • alias String

    The sound alias to check for.

Returns:

Bool:

true if the alias is in the spritemap, false otherwise.

init

(
  • dataURLorObject
  • onReady
)
public static

Defined in init:158

Static constructor initializing Audio (and soundManager)

Parameters:

  • dataURLorObject String | Object

    The optional sprite data url or sprite json object

  • onReady Function

    function to call when Audio finished initializing

initialize

(
  • dataURLorObject
  • onReady
)

Defined in initialize:186

Audio controller constructor

Parameters:

  • dataURLorObject String | Object

    The optional sprite data url or sprite json object

  • onReady Function

    The callback function to call when finished initializing

isLooping

(
  • alias
)
public

Defined in isLooping:707

Returns value of loop property for named sound

Parameters:

  • alias Bool

    If the alias is set to loop

isPlaying

() Bool public

Defined in isPlaying:382

Returns true if a sound is currently being played

Returns:

Bool:

If the audio is current playing

isReady

(
  • alias
)
Bool private

Defined in isReady:272

Check to make sure the audio is ready

Parameters:

  • alias String*

    Optional alias to check for valid sprite sound

Returns:

Bool:

If we can proceed with task

load

(
  • callback
)
public

Defined in load:316

Preload audio data for primary sprite, MUST be called by a click/touch event!!!

Parameters:

  • callback Function

    The callback function to call on load complete

mute

() public

Defined in mute:660

Set if the audio is muted

pause

() public

Defined in pause:393

Used if we need to pause the current sound and resume later

play

(
  • alias
  • onFinish
  • onStart
  • onUpdate
)
public

Defined in play:438

Play sound from sprite by Alias

Parameters:

  • alias String

    Name of sound to play

  • onFinish Function

    Function called when the sound is done

  • onStart Function

    Function to be called when playback starts. This is called immediately, and is here to provide compatibility in usage with cloudkid.Sound.

  • onUpdate Function

    Function to return the current progress amount 0 to 1

prepare

(
  • alias
)
public

Defined in prepare:370

Goto the beginning of a sound

Parameters:

  • alias String

    The sound alias

resume

() public

Defined in resume:414

Used to resume sound paused with pause();

stop

(
  • doCallback
)
public

Defined in stop:604

Used if we need to stop playing a sound and we don't need to resume from the current position

Parameters:

  • doCallback Bool

    If the callback should be called after stop

unmute

() public

Defined in unmute:678

Set if the audio should turn off mute mode

validateData

(
  • data
  • callback
)
private

Defined in validateData:245

Validate that the sprite data is alright

Parameters:

  • data Object

    The audiosprite data

  • callback Function

    Method to call when we're completed

Properties

_audioSprite

cloudkid.SwishSprite private

Defined in _audioSprite:122

Instance of the SwishSprite class

_currentAlias

String private

Defined in _currentAlias:49

The current alias of the sound playing

_currentData

Object private

Defined in _currentData:42

Contains start + stop times for current sound

_currentInst

AudioInst private

Defined in _currentInst:136

The currently playing (and thus valid) AudioInst object.

_data

Dictionary private

Defined in _data:27

Metadata regarding Primary Audio Sprite (URLs, Audio Timings)

_data

Bool private

Defined in _data:34

If the Audio instance has been destroyed

Default: false

_duration

Number private

Defined in _duration:92

The length of silence to play in seconds

_instance

Audio private

Defined in _instance:129

Singleton instance of sound player

_muted

Bool private

Defined in _muted:85

If the sounds are muted

_onFinish

Function private

Defined in _onFinish:56

Function to call when sound reaches end

_onUpdate

Function private

Defined in _onUpdate:63

Update the function

_paused

Bool private

Defined in _paused:70

Set true only if paused by pause() used to determine validity of resume()

Default: false

_progress

Number private

Defined in _progress:78

The current progress amount from 0 to 1

_silencePosition

Number private

Defined in _silencePosition:99

The postion we're currently on if muted

_updateAlias

String private

Defined in _updateAlias:106

The silence update alias

Default: AudioMute

_updateSpriteAlias

String private

The alias for the audiosprite update

Default: SwishSprite

instance

Audio public static

Defined in instance:175

Static function for getting the singleton instance

soundLoaded

Bool public

Defined in soundLoaded:143

If the sound file is loaded

VERSION

String public static

Defined in VERSION:150

The global version of the library