springroll.VOPlayer Class

Module: Sound

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

_onSoundFinished

()
private

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

_playSound

()
private

Defined in _playSound:485

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

_syncCaptionToSound

(
  • 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.

_updateSilence

(
  • elapsed
)
private

Defined in _updateSilence:436

The update callback used for silence timers. This method is bound to the VOPlayer instance.

Parameters:

  • elapsed Int

    The time elapsed since the previous frame, in milliseconds.

_updateSoloCaption

(
  • elapsed
)
private

The update callback used for 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.

destroy

()
public

Defined in destroy:577

Cleans up this VOPlayer.

getElapsed

() Int

Defined in getElapsed:237

Calculates the amount of time elapsed in the current playlist of audio/silence.

Returns:

Int:

The elapsed time in milliseconds.

pause

()
public

Defined in pause:281

Pauses the current VO, caption, or silence timer if the VOPlayer is playing.

play

(
  • idOrList
  • [callback]
  • [cancelledCallback]
)
public

Defined in play:329

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

Parameters:

  • idOrList String | Array

    The alias of the audio file to play or the array of items to play/call in order.

  • [callback] Function optional

    The function to call when playback is complete.

  • [cancelledCallback] Function | Boolean optional

    The function to call when playback is interrupted with a stop() or play() call. If this value is a boolean true then callback will be used instead.

resume

()
public

Defined in resume:302

Resumes the current VO, caption, or silence timer if the VOPlayer was paused.

stop

()
public

Defined in stop:531

Stops playback of any audio/timer.

unloadSound

()
public

Defined in unloadSound:566

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

_callback

Function private

Defined in _callback:89

The callback for when the list is finished.

_cancelledCallback

Function private

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

_captions

springroll.Captions private

Defined in _captions:117

The captions object

_currentVO

String private

Defined in _currentVO:75

The current audio alias being played.

_listCounter

Int private

Defined in _listCounter:68

The current position in voList.

_listHelper

Array private

Defined in _listHelper:36

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

_soundInstance

SoundInstance private

Defined in _soundInstance:82

The current audio instance being played.

_timer

Int private

Defined in _timer:110

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

_trackedSounds

Array private

Defined in _trackedSounds:103

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

captions

Captions public

Defined in captions:170

The springroll.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.

currentDuration

Int

Defined in currentDuration:214

The duration of the currently playing item of audio/silence in milliseconds. If this is waiting on an audio file to load for the first time, it will be 0, as there is no duration data to give.

currentPosition

Int

Defined in currentPosition:193

The amount of time elapsed in the currently playing item of audio/silence in milliseconds

currentVO

Boolean public

Defined in currentVO:155

The current VO alias that is playing, even if it is just a caption. If a silence timer is running, currentVO will be null.

paused

Boolean public

Defined in paused:51

If the sound is currently paused. Setting this has no effect - use pause() and resume().

playing

Boolean public

Defined in playing:141

If VOPlayer is currently playing (audio or silence).

soundList

Unknown deprecated public

Defined in soundList:119

Deprecated: since version 0.4.0

Get the current list of VO sounds, see voList

trackSound

Boolean public

Defined in trackSound:43

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

voList

Array public

Defined in voList:60

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

end

Defined in end:134

Fired when a new VO, caption, or silence timer completes

Event Payload:

  • currentVO String

    The alias of the VO or caption that has begun, or null if it is a silence timer.

start

Defined in start:127

Fired when a new VO, caption, or silence timer begins

Event Payload:

  • currentVO String

    The alias of the VO or caption that has begun, or null if it is a silence timer.