API Documentation for: 1.1.1
Show:

Captions Class

Defined in: Captions:10
Namespace: cloudkid

A class that creates captioning for multimedia content. Captions are created from a dictionary of captions and can be played by alias. Captions is a singleton class and depends on cloudkid.Audio for the progress update.

Constructor

Captions

(
  • [captionDictionary=null]
  • [field=null]
)

Defined in Captions:10

Parameters:

  • [captionDictionary=null] Dictionary optional

    The dictionary of captions

  • [field=null] createjs.Text optional

    An text field to use as the output for this captions object

Example:

    var captionsDictionary = {
        "Alias1": [
            {"start":0, "end":2000, "content":"Ohh that looks awesome!"}
        ],
        "Alias2": [
            {"start":0, "end":2000, "content":"Love it, absolutely love it!"}
        ]
    };

    var captions = new cloudkid.Captions(captionsDictionary);
    captions.play("Alias1");

Methods

_calcUpdate

() private

Defined in _calcUpdate:698

Calculates the captions after increasing the current time.

_getTotalDuration

() private

Calculate the total duration of the current caption

_load

(
  • data
)
private

Defined in _load:389

Sets an array of line data as the current caption data to play.

Parameters:

_onSoundComplete

() private

Is called when cloudkid.Audio finishes playing. Is not called if a cloudkid.AudioAnimation finishes playing, as then stop() is called.

_reset

() private

Defined in _reset:412

Reset the captions

_timeCodeToMilliseconds

(
  • input
)
Int private

Take the captions timecode and convert to milliseconds format is in HH:MM:ss:mmm

Parameters:

  • input String

    The input string of the format

Returns:

Int:

Time in milliseconds

_updateCaptions

() private

Defined in _updateCaptions:735

Updates the text in the managed text field.

_updatePercent

(
  • progress
)
private

Defined in _updatePercent:669

Callback for when a frame is entered.

Parameters:

  • progress Number

    The progress in the current sound as a percentage (0-1)

_updateToAnim

() private

Defined in _updateToAnim:647

Callback for when a frame is entered, to sync to an animation's audio.

destroy

()

Defined in destroy:753

Destroy this load task and don't use after this

getFullCaption

(
  • alias
  • [separator="
)
String

Defined in getFullCaption:353

A utility function for getting the full text of a caption by alias this can be useful for debugging purposes.

Parameters:

  • alias String

    The alias to get the text of

  • [separator=" String

    "] The separation between each line

Returns:

String:

The entire captions concatinated by the separator

getMuteAll

() Bool public static

Defined in getMuteAll:264

If the captions are all currently muted.

Returns:

Bool:

Whether the captions are all muted

hasCaption

(
  • alias
)
Bool

Defined in hasCaption:341

Returns if there is a caption under that alias or not.

Parameters:

  • alias String

    The alias to check against

Returns:

Bool:

Whether the caption was found or not

init

(
  • [captionDictionary=null]
  • [field=null]
)
public static

Defined in init:202

Creates the singleton instance of Captions, with an optional dictionary ready to go

Parameters:

  • [captionDictionary=null] Object optional

    An object set up in dictionary format of caption objects.

  • [field=null] createjs.Text optional

    An text field to use as the output for this captions object

initialize

(
  • [captionDictionary=null]
  • [field=null]
)
private

Defined in initialize:231

Constructor for caption.

Parameters:

  • [captionDictionary=null] Object optional

    An object set up in dictionary format of caption objects.

  • [field=null] createjs.Text | PIXI.Text | PIXI.BitmapText optional

    An text field to use as the output for this captions object. When using PIXI textfields, textIsProp should be false.

isPlaying

() Bool public

Defined in isPlaying:445

The playing status.

Returns:

Bool:

If the caption is playing

play

(
  • alias
  • callback
)
Function public

Defined in play:490

Start the caption playback. Captions will tell cloudkid.Audio to play the proper sound.

Parameters:

  • alias String

    The desired caption's alias

  • callback Function

    The function to call when the caption is finished playing

Returns:

Function:

The update function that should be called if captions isSlave is true

run

(
  • alias
)
Function deprecated public

Defined in run:525

Deprecated: Use play(alias) instead, isSlave should be set to true

Starts caption playback without controlling the sound or animation. Returns the update function that should be called to control the Captions object.

Parameters:

  • alias String

    The caption/sound alias

Returns:

Function:

The update function that should be called

runWithAnimation

(
  • animTimeline
)
deprecated public

Defined in runWithAnimation:543

Deprecated: Set Animator.captions or PixiAnimator.captions to set the captions object to use

Runs a caption synced to the audio of an animation.

Parameters:

  • animTimeline cloudkid.AnimatorTimeline | cloudkid.PixiAnimator.AnimTimeline

    The animation to sync to.

seek

(
  • time
)
public

Defined in seek:601

Goto a specific time.

Parameters:

  • time Int

    The time in milliseconds to seek to in the captions

setDictionary

(
  • dict
)
public

Defined in setDictionary:277

Sets the dictionary object to use for captions. This overrides the current dictionary, if present.

Parameters:

  • dict Dictionary

    The dictionary object to use for captions.

setMuteAll

(
  • muteAll
)
public static

Defined in setMuteAll:248

Mute all of the captions.

Parameters:

  • muteAll Bool

    Whether to mute or unmute

setTextField

(
  • field
)
public

Defined in setTextField:321

Sets the CreateJS Text or Pixi BitmapText/Text object that Captions should control the text of. Only one text field can be controlled at a time. When using PIXI textfields, textIsProp should be false.

Parameters:

  • field createjs.Text | PIXI.Text | PIXI.BitmapText

    The CreateJS or PIXI Text object

stop

() public

Defined in stop:576

Convience function for stopping captions. Is also called by cloudkid.AudioAnimation when it is finished.

updateTime

(
  • progress
)
public

Defined in updateTime:683

Function to update the amount of time elapsed for the caption playback. Call this to advance the caption by a given amount of time.

Parameters:

  • progress Int

    The time elapsed since the last frame in milliseconds

Properties

_animTimeline.

cloudkid.AnimatorTimeline | cloudkid.PixiAnimator.AnimTimeline private

Defined in _animTimeline.:160

An animation timeline from Animator or PixiAnimator. This is used for syncing captions to audio that is synced with with an animation.

_boundComplete

Function private

Defined in _boundComplete:185

A bound completion callback for when Sound has finished playing.

_boundUpdate

Function private

Defined in _boundUpdate:177

A bound update function to get the progress from Sound with

_captionDict

Dictionary private

Defined in _captionDict:50

An object used as a dictionary with keys that should be the same as sound aliases

_completeCallback

Function private

The function to call when playback is complete.

_currentDuration

Int private

Defined in _currentDuration:84

The duration in milliseconds of the current sound.

_currentLine

Int private

Defined in _currentLine:100

Save the current line index

_currentTime

Int private

Defined in _currentTime:92

The current playback time

_instance

Captions private

Defined in _instance:124

The singleton instance of Captions

_isDestroyed

Bool private

Defined in _isDestroyed:169

If this instance has been destroyed already

_isSlave

Bool private

Defined in _isSlave:140

If this Captions instance is a 'slave', that doesn't run cloudkid.Audio and must have update() called manually (and passed milliseconds). Default is false.

_lastActiveLine

Int private

Defined in _lastActiveLine:108

Cache the last active line

_lines

Array private

Defined in _lines:76

The collection of line objects {start:0, end:0, content:""}

_muteAll

Bool private

Defined in _muteAll:132

If you want to mute the captions, doesn't remove the current caption

_playing

Bool private

Defined in _playing:116

If we're playing

_textField

createjs.Text | PIXI.Text | PIXI.BitmapText private

Defined in _textField:58

A reference to the CreateJS Text object that Captions should be controlling. Only one text field can be controlled at a time. When using PIXI textfields, textIsProp should be false.

currentDuration

Int

Defined in currentDuration:468

Get the current duration of the current caption

instance

Captions public static

Defined in instance:216

The singleton instance of Captions

isSlave

Bool

Defined in isSlave:478

If this Captions instance is a 'slave', that doesn't run cloudkid.Audio and must have update() called manually (and passed milliseconds).

Default: false

p

Object private

Defined in p:42

Reference to the inherieted task

textIsProp

Bool private

Defined in textIsProp:150

If text should be set on the text field with '.text = ' instead of '.setText()'. When using PIXI textfields, textIsProp should be false. Default is true.

VERSION

String public static

Defined in VERSION:193

The version number of this library