API Documentation for: 3.0.0
Show:

VOPlayer Class

Defined in: VOPlayer:14
Namespace: cloudkid

A class for managing audio by only playing one at a time, playing a list, and even managing captions (CloudKidCaptions library) at the same time.

Constructor

VOPlayer

(
  • [useCaptions=false]
)

Defined in VOPlayer:14

Parameters:

  • [useCaptions=false] Bool | cloudkid.Captions optional

    If a cloudkid.Captions object should be created for use or the captions object to use

Methods

_onAudioFinished

() private

Callback for when audio/timer is finished to advance to the next item in the list.

_playAudio

() private

Defined in _playAudio:254

Plays the current audio item and begins preloading the next item.

_update

(
  • elapsed
)
private

Defined in _update:223

The update callback used for silence timers and updating captions without active audio. This method is bound to the VOPlayer instance.

Parameters:

  • elapsed Int

    The time elapsed since the previous frame, in milliseconds.

_updateCaptionPos

(
  • elapsed
)
private

The update callback used for updating captions with active audio. This method is bound to the VOPlayer instance.

Parameters:

  • elapsed Int

    The time elapsed since the previous frame, in milliseconds.

destroy

() public

Defined in destroy:338

Cleans up this VOPlayer.

play

(
  • id
  • callback
  • cancelledCallback
)
public

Defined in play:139

Plays a single audio alias, interrupting any current playback.

Parameters:

  • id String

    The alias of the audio file to play.

  • callback Function

    The function to call when playback is complete.

  • cancelledCallback Function

    The function to call when playback is interrupted with a stop(), play() or playList() call.

playList

(
  • list
  • callback
  • cancelledCallback
)
public

Defined in playList:159

Plays a list of audio files, timers, and/or functions, interrupting any current playback. Audio in the list will be preloaded to minimize pauses for loading.

Parameters:

  • list Array

    The array of items to play/call in order.

  • callback Function

    The function to call when playback is complete.

  • cancelledCallback Function

    The function to call when playback is interrupted with a stop(), play() or playList() call.

stop

() public

Defined in stop:304

Stops playback of any audio/timer.

unloadPlayedAudio

() public

Unloads all audio this VOPlayer has played. If trackAudio is false, this won't do anything.

Properties

_audioInst

SoundInst private

Defined in _audioInst:70

The current audio instance being played.

_audioListener

Function private

Defined in _audioListener:91

The bound _onAudioFinished call.

_callback

Function private

Defined in _callback:77

The callback for when the list is finished.

_cancelledCallback

Function private

The callback for when the list is interrupted for any reason.

_currentAudio

String private

Defined in _currentAudio:63

The current audio alias being played.

_listCounter

Int private

Defined in _listCounter:56

The current position in audioList.

_listHelper

Array private

Defined in _listHelper:120

An Array used when play() is called to avoid creating lots of Array objects.

_playedAudio

Array private

Defined in _playedAudio:98

A list of audio file played by this, so that they can be unloaded later.

_timer

Int private

Defined in _timer:105

A timer for silence entries in the list, in milliseconds.

audioList

Array public

Defined in audioList:49

The current list of audio/silence times/functions. Generally you will not need to modify this.

captions

cloudkid.Captions public

Defined in captions:112

The cloudkid.Captions object used for captions. The developer is responsible for initializing this with a captions dictionary config file and a reference to a text field.

playing

Bool public

Defined in playing:128

If VOPlayer is currently playing (audio or silence).

trackAudio

Bool public

Defined in trackAudio:42

If the VOPlayer should keep a list of all audio it plays for unloading later. Default is false.