A class that creates captioning for multimedia content. Captions are created from a dictionary of captions and can be played by alias.
springroll.Captions
[data=null]
[textField=null]
[selfUpdate=true]
var captionsData = {
"Alias1": [
{"start":0, "end":2000, "content":"Ohh that looks awesome!"}
],
"Alias2": [
{"start":0, "end":2000, "content":"Love it, absolutely love it!"}
]
};
//initialize the captions
var captions = new springroll.Captions();
captions.data = captionsData;
captions.textField = document.getElementById("captions");
captions.play("Alias1");
_load
data
Sets an array of line data as the current caption data to play.
data
String
The string
_timeCodeToMilliseconds
input
Take the captions timecode and convert to milliseconds format is in HH:MM:ss:mmm
input
String
The input string of the format
Time in milliseconds
_updatePercent
progress
Callback for when a frame is entered.
progress
Number
The progress in the current sound as a percentage (0-1)
getFullCaption
alias
[separator=" "]
A utility function for getting the full text of a caption by alias this can be useful for debugging or tracking purposes.
The entire caption, concatinated by the separator.
getLength
alias
Returns duration in milliseconds of given captioned sound alias or alias list.
Length/duration of caption in milliseconds.
hasCaption
alias
Returns if there is a caption under that alias or not.
alias
String
The alias to check against
Whether the caption was found or not
seek
time
Goto a specific time.
time
Int
The time in milliseconds to seek to in the captions
setText
field
text
Automatically determine how to set the text field text
field
createjs.Text | PIXI.Text | PIXI.BitmapText | DOMElement
The text field to change
text
String
The text to set it to
The text field
_data
An object used as a dictionary with keys that should be the same as sound aliases
_textField
A reference to the Text object that Captions should be controlling. Only one text field can be controlled at a time.
data
Sets the dictionary object to use for captions. This overrides the current dictionary, if present.
selfUpdate
If the captions object should do it's own updating unless you want to manuall seek. In general, self-updating should not be set to false unless the sync of the captions needs to be exact with something else.
Default: true
textField
The text field that the captions uses to update.