libjass

Variables

Map

Set to browser's implementation of Map if it has one, else set to libjass.SimpleMap

var result = libjass.Map;
libjass.Map = value;
function(new:Map)
Promise

Set to browser's implementation of Promise if it has one, else set to libjass.SimplePromise

var result = libjass.Promise;
libjass.Promise = value;
function(new:Promise)
Set

Set to browser's implementation of Set if it has one, else set to libjass.SimpleSet

var result = libjass.Set;
libjass.Set = value;
function(new:Set)
debugMode

Debug mode. When true, libjass logs some debug messages.

var result = libjass.debugMode;
libjass.debugMode = value;
boolean
verboseMode

Verbose debug mode. When true, libjass logs some more debug messages. This setting is independent of libjass.debugMode

var result = libjass.verboseMode;
libjass.verboseMode = value;
boolean

Free functions

mixin

Adds properties of the given mixins' prototypes to the given class's prototype.

libjass.mixin(clazz, mixins);
clazz
!*
mixins
!Array.<*>
_valueOrDefault.<T>

var result = _valueOrDefault(template, key, converter, validator, defaultValue);
template
!Map.<string, string>
key
string
converter
function(string):T
validator
?function(T):boolean
defaultValue
T
Returns
T

Interfaces

interface Property

A property.

name

var result = property.name;
property.name = value;
string
value

var result = property.value;
property.value = value;
string
interface TypedTemplate

A template object with a particular type.

template

var result = typedTemplate.template;
typedTemplate.template = value;
!Map.<string, string>
type

var result = typedTemplate.type;
typedTemplate.type = value;
string

Classes

class ASS

This class represents an ASS script. It contains the libjass.ScriptProperties, an array of libjass.Styles, and an array of libjass.Dialogues.

var ass = new libjass.ASS();
dialogues
Getter

The dialogues in this script.

var result = ass.dialogues;
!Array.<!libjass.Dialogue>
dialoguesFormatSpecifier
Getter

The format specifier for the styles section.

var result = ass.dialoguesFormatSpecifier;
!Array.<string>
Setter

The format specifier for the events section.

ass.dialoguesFormatSpecifier = value;
value
!Array.<string>
properties
Getter

The properties of this script.

var result = ass.properties;
!libjass.ScriptProperties
styles
Getter

The styles in this script.

var result = ass.styles;
!Map.<string, !libjass.Style>
stylesFormatSpecifier
Getter

The format specifier for the styles section.

var result = ass.stylesFormatSpecifier;
!Array.<string>
Setter

The format specifier for the events section.

ass.stylesFormatSpecifier = value;
value
!Array.<string>
addEvent

Add an event to this ASS script.

ass.addEvent(line);
line
string
The line from the script that contains the new event.
addStyle

Add a style to this ASS script.

ass.addStyle(line);
line
string
The line from the script that contains the new style.
fromStream

Creates an ASS object from the given libjass.parser.Stream.

var result = libjass.ASS.fromStream(stream, type);
stream
!libjass.parser.Stream
The stream to parse the script from
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
fromString

Creates an ASS object from the raw text of an ASS script.

var result = libjass.ASS.fromString(raw, type);
raw
string
The raw text of the script.
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
fromUrl

Creates an ASS object from the given URL.

var result = libjass.ASS.fromUrl(url, type);
url
string
The URL of the script.
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
class DeferredPromise.<T>

A deferred promise.

var deferredPromise = new libjass.DeferredPromise();
promise
Getter

var result = deferredPromise.promise;
!Promise.<T>
reject

deferredPromise.reject(reason);
reason
*
resolve

deferredPromise.resolve(value);
value
T
class Dialogue

This class represents a dialogue in a libjass.ASS script.

var dialogue = new libjass.Dialogue(template, ass);
template
!Map.<string, string>
The template object that contains the dialogue's properties. It is a map of the string values read from the ASS file.
"Style"
string
The name of the default style of this dialogue
"Start"
string
The start time
"End"
string
The end time
"Layer"
string
The layer number
"Text"
string
The text of this dialogue
ass
ASS
The ASS object to which this dialogue belongs
alignment
Getter

The alignment number of this dialogue.

var result = dialogue.alignment;
number
end
Getter

The end time of this dialogue.

var result = dialogue.end;
number
id
Getter

The unique ID of this dialogue. Auto-generated.

var result = dialogue.id;
number
layer
Getter

The layer number of this dialogue.

var result = dialogue.layer;
number
parts
Getter

The libjass.parts of this dialogue.

var result = dialogue.parts;
!Array.<!libjass.parts.Part>
start
Getter

The start time of this dialogue.

var result = dialogue.start;
number
style
Getter

The default style of this dialogue.

var result = dialogue.style;
!libjass.Style
toString

var result = dialogue.toString();
Returns
string
A simple representation of this dialogue's properties and parts.
_parsePartsString

Parses this dialogue's parts from the raw parts string.

dialogue._parsePartsString();
_toTime

Converts this string into the number of seconds it represents. This string must be in the form of hh:mm:ss.MMM

var result = libjass.Dialogue._toTime(str);
str
string
Returns
number
class ScriptProperties

This class represents the properties of a libjass.ASS script.

var scriptProperties = new libjass.ScriptProperties();
resolutionX
Getter

The horizontal script resolution.

var result = scriptProperties.resolutionX;
number
Setter

The horizontal script resolution.

scriptProperties.resolutionX = value;
value
number
resolutionY
Getter

The vertical script resolution.

var result = scriptProperties.resolutionY;
number
Setter

The vertical script resolution.

scriptProperties.resolutionY = value;
value
number
scaleBorderAndShadow
Getter

Whether to scale outline widths and shadow depths from script resolution to video resolution or not. If true, widths and depths are scaled.

var result = scriptProperties.scaleBorderAndShadow;
boolean
Setter

Whether to scale outline widths and shadow depths from script resolution to video resolution or not. If true, widths and depths are scaled.

scriptProperties.scaleBorderAndShadow = value;
value
boolean
wrappingStyle
Getter

The wrap style. One of the libjass.WrappingStyle constants.

var result = scriptProperties.wrappingStyle;
number
Setter

The wrap style. One of the libjass.WrappingStyle constants.

scriptProperties.wrappingStyle = value;
value
number
class Style

This class represents a single global style declaration in a libjass.ASS script. The styles can be obtained via the libjass.ASS.styles property.

var style = new libjass.Style(template);
template
!Map.<string, string>
The template object that contains the style's properties. It is a map of the string values read from the ASS file.
"Name"
string
The name of the style
"Italic"
string
-1 if the style is italicized
"Bold"
string
-1 if the style is bold
"Underline"
string
-1 if the style is underlined
"StrikeOut"
string
-1 if the style is struck-through
"Fontname"
string
The name of the font
"Fontsize"
string
The size of the font
"ScaleX"
string
The horizontal scaling of the font
"ScaleY"
string
The vertical scaling of the font
"Spacing"
string
The letter spacing of the font
"PrimaryColour"
string
The primary color
"OutlineColour"
string
The outline color
"BackColour"
string
The shadow color
"Outline"
string
The outline thickness
"Shadow"
string
The shadow depth
"Alignment"
string
The alignment number
"MarginL"
string
The left margin
"MarginR"
string
The right margin
"MarginV"
string
The vertical margin
alignment
Getter

The alignment of dialogues of this style.

var result = style.alignment;
number
bold
Getter

Whether this style is bold or not.

var result = style.bold;
boolean
borderStyle
Getter

The border style of this style.

var result = style.borderStyle;
number
fontName
Getter

The name of this style's font.

var result = style.fontName;
string
fontScaleX
Getter

The horizontal scaling of this style's font.

var result = style.fontScaleX;
number
fontScaleY
Getter

The vertical scaling of this style's font.

var result = style.fontScaleY;
number
fontSize
Getter

The size of this style's font.

var result = style.fontSize;
number
italic
Getter

Whether this style is italicized or not.

var result = style.italic;
string
letterSpacing
Getter

The letter spacing scaling of this style's font.

var result = style.letterSpacing;
number
marginLeft
Getter

The left margin of dialogues of this style.

var result = style.marginLeft;
number
marginRight
Getter

The right margin of dialogues of this style.

var result = style.marginRight;
number
marginVertical
Getter

The vertical margin of dialogues of this style.

var result = style.marginVertical;
number
name
Getter

The name of this style.

var result = style.name;
string
outlineColor
Getter

The color of this style's outline.

var result = style.outlineColor;
!libjass.parts.Color
outlineThickness
Getter

The thickness of this style's outline.

var result = style.outlineThickness;
number
primaryColor
Getter

The color of this style's font.

var result = style.primaryColor;
!libjass.parts.Color
rotationZ
Getter

The default Z-rotation of this style.

var result = style.rotationZ;
number
secondaryColor
Getter

The alternate color of this style's font, used in karaoke.

var result = style.secondaryColor;
!libjass.parts.Color
shadowColor
Getter

The color of this style's shadow.

var result = style.shadowColor;
!libjass.parts.Color
shadowDepth
Getter

The depth of this style's shadow.

var result = style.shadowDepth;
number
strikeThrough
Getter

Whether this style is struck-through or not.

var result = style.strikeThrough;
boolean
underline
Getter

Whether this style is underlined or not.

var result = style.underline;
boolean
class SimpleMap.<K, V>

Map implementation for browsers that don't support it. Only supports keys which are of Number or String type, or which have a property called "id". Keys and values are stored as properties of an object, with property names derived from the key type.

var simpleMap = new SimpleMap();
size
Getter

var result = simpleMap.size;
number
clear

simpleMap.clear();
delete

var result = simpleMap.delete(key);
key
K
Returns
boolean
true if the key was present before being deleted, false otherwise
forEach

simpleMap.forEach(callbackfn, thisArg);
callbackfn
function(V, K, libjass.Map.<K, V>)
A function that is called with each key and value in the map.
thisArg
*
get

var result = simpleMap.get(key);
key
K
Returns
V
has

var result = simpleMap.has(key);
key
K
Returns
boolean
set

var result = simpleMap.set(key, value);
key
K
value
V
Returns
libjass.Map.<K, V>
This map
_keyToProperty

Converts the given key into a property name for the internal map.

var result = simpleMap._keyToProperty(key);
key
K
Returns
string
class SimplePromise.<T>

Promise implementation for browsers that don't support it.

var simplePromise = new SimplePromise(resolver);
resolver
function(function(T), function(*))
all.<T>

var result = SimplePromise.all(promises);
promises
!Array.<!Promise.<T>>
Returns
!Promise.<!Array.<T>>
isFulfilled

var result = simplePromise.isFulfilled();
Returns
boolean
isPending

var result = simplePromise.isPending();
Returns
boolean
isRejected

var result = simplePromise.isRejected();
Returns
boolean
reason

var result = simplePromise.reason();
Returns
*
resolve.<T>

var result = SimplePromise.resolve(value);
value
T
Returns
!Promise.<T>
then.<U>

var result = simplePromise.then(fulfilledHandler, rejectedHandler);
fulfilledHandler
function(T):(U|Promise.<U>)
rejectedHandler
?function(*):(U|Promise.<U>)
Returns
!Promise.<U>
value

var result = simplePromise.value();
Returns
T
_fulfill

simplePromise._fulfill(value);
value
T
_getThenMethod.<T>

var result = SimplePromise._getThenMethod(obj);
obj
!*
Returns
?function(function(T):T, function(*):T):!Promise.<T>
_propagateResolution

Propagates the result of the current promise to all its children.

simplePromise._propagateResolution();
_reject

simplePromise._reject(reason);
reason
*
_resolve

simplePromise._resolve(value);
value
T
class SimpleSet.<T>

Set implementation for browsers that don't support it. Only supports Number and String elements. Elements are stored as properties of an object, with names derived from their type.

var simpleSet = new SimpleSet();
size
Getter

var result = simpleSet.size;
number
add

var result = simpleSet.add(value);
value
T
Returns
libjass.Set.<T>
This set
clear

simpleSet.clear();
delete

Not implemented.

var result = simpleSet.delete(value);
value
T
Returns
boolean
forEach

simpleSet.forEach(callbackfn, thisArg);
callbackfn
function(T, T, libjass.Set.<T>)
A function that is called with each value in the set.
thisArg
*
has

var result = simpleSet.has(value);
value
T
Returns
boolean
_toProperty

Converts the given value into a property name for the internal map.

var result = simpleSet._toProperty(value);
value
T
Returns
string

Enums

enum BorderStyle

The border style defined in the libjass.Style properties.

Outline = 1

OpaqueBox = 3

enum Format

The format of the string passed to libjass.ASS.fromString

ASS = 0

SRT = 1

enum WrappingStyle

The wrapping style defined in the libjass.ScriptProperties

SmartWrappingWithWiderTopLine = 0

SmartWrappingWithWiderBottomLine = 3

EndOfLineWrapping = 1

NoLineWrapping = 2

enum SimplePromiseState

The state of the libjass.SimplePromise

PENDING = 0

FULFILLED = 1

REJECTED = 2

libjass.parser

Free functions

parse

Parses a given string with the specified rule.

var result = libjass.parser.parse(input, rule);
input
string
The string to be parsed.
rule
string
The rule to parse the string with
Returns
*
The value returned depends on the rule used.
parseLineIntoProperty

Parses a line into a libjass.Property.

var result = libjass.parser.parseLineIntoProperty(line);
line
string
Returns
!libjass.Property
parseLineIntoTypedTemplate

Parses a line into a libjass.TypedTemplate according to the given format specifier.

var result = libjass.parser.parseLineIntoTypedTemplate(line, formatSpecifier);
line
string
formatSpecifier
!Array.<string>
Returns
!libjass.TypedTemplate
makeTagParserFunction

Constructs a simple tag parser function and sets it on the ParserRun class's prototype.

makeTagParserFunction(tagName, tagConstructor, valueParser, required);
tagName
string
The name of the tag to generate the parser function for
tagConstructor
function(new: !libjass.parts.Part, *)
The type of tag to be returned by the generated parser function
valueParser
function(!ParseNode): ParseNode
The parser for the tag's value
required
boolean
Whether the tag's value is required or optional

Interfaces

interface Stream

An interface for a stream.

nextLine

var result = stream.nextLine();
Returns
!Promise.<string>
A promise that will be resolved with the next line, or null if the stream is exhausted.

Classes

class ParseNode

This class represents a single parse node. It has a start and end position, and an optional value object.

var parseNode = new libjass.parser.ParseNode(parent, value);
parent
libjass.parser.ParseNode
The parent of this parse node.
value
*=null
If provided, it is assigned as the value of the node.
children
Getter

var result = parseNode.children;
!Array.<!ParseNode>
end
Getter

The end position of this parse node.

var result = parseNode.end;
number
parent
Getter

var result = parseNode.parent;
libjass.parser.ParseNode
start
Getter

The start position of this parse node.

var result = parseNode.start;
number
value
Getter

An optional object associated with this parse node.

var result = parseNode.value;
*
Setter

An optional object associated with this parse node. If the value is a string, then the end property is updated to be the length of the string.

parseNode.value = value;
value
*
pop

Removes the last child of this node and updates the end position to be end position of the new last child.

parseNode.pop();
_setEnd

Updates the end property of this node and its parent recursively to the root node.

parseNode._setEnd(newEnd);
newEnd
number
class SrtStreamParser

A parser that parses an libjass.ASS object from a libjass.parser.Stream of an SRT script.

var srtStreamParser = new libjass.parser.SrtStreamParser(stream);
stream
!libjass.parser.Stream
The libjass.parser.Stream to parse
ass
Getter

var result = srtStreamParser.ass;
!Promise.<!libjass.ASS>
_onNextLine

srtStreamParser._onNextLine(line);
line
string
class StreamParser

A parser that parses an libjass.ASS object from a libjass.parser.Stream.

var streamParser = new libjass.parser.StreamParser(stream);
stream
!libjass.parser.Stream
The libjass.parser.Stream to parse
ass
Getter

var result = streamParser.ass;
!Promise.<!libjass.ASS>
minimalASS
Getter

parsed at the point this promise becomes resolved.

var result = streamParser.minimalASS;
!Promise.<!libjass.ASS>
_onNextLine

streamParser._onNextLine(line);
line
string
class StringStream

A libjass.parser.Stream that reads from a string in memory.

var stringStream = new libjass.parser.StringStream(str);
str
string
The string
nextLine

var result = stringStream.nextLine();
Returns
!Promise.<string>
A promise that will be resolved with the next line, or null if the string has been completely read.
class XhrStream

A libjass.parser.Stream that reads from an XMLHttpRequest object.

var xhrStream = new libjass.parser.XhrStream(xhr);
xhr
!XMLHttpRequest
The XMLHttpRequest object
nextLine

var result = xhrStream.nextLine();
Returns
!Promise.<string>
A promise that will be resolved with the next line, or null if the stream is exhausted.
_onXhrLoadEnd

xhrStream._onXhrLoadEnd(event);
event
!ProgressEvent
_onXhrProgress

xhrStream._onXhrProgress(event);
event
!ProgressEvent
_reportNewLine

xhrStream._reportNewLine();
class ParserRun

This class represents a single run of the parser.

var parserRun = new ParserRun(input, rule);
input
string
rule
string
result
Getter

var result = parserRun.result;
libjass.parser.ParseNode
parse_alpha

var result = parserRun.parse_alpha(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_color

var result = parserRun.parse_color(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_colorWithAlpha

var result = parserRun.parse_colorWithAlpha(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_comment

var result = parserRun.parse_comment(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_decimal

var result = parserRun.parse_decimal(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_decimalInt32

var result = parserRun.parse_decimalInt32(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_decimalOrHexInt32

var result = parserRun.parse_decimalOrHexInt32(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_dialogueParts

var result = parserRun.parse_dialogueParts(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_drawingInstructionCubicBezierCurve

var result = parserRun.parse_drawingInstructionCubicBezierCurve(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_drawingInstructionLine

var result = parserRun.parse_drawingInstructionLine(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_drawingInstructionMove

var result = parserRun.parse_drawingInstructionMove(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_drawingInstructions

var result = parserRun.parse_drawingInstructions(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_enableDisable

var result = parserRun.parse_enableDisable(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_enclosedTags

var result = parserRun.parse_enclosedTags(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_hardspace

var result = parserRun.parse_hardspace(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_hexInt32

var result = parserRun.parse_hexInt32(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_newline

var result = parserRun.parse_newline(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_1a

var result = parserRun.parse_tag_1a(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_1c

var result = parserRun.parse_tag_1c(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_2a

var result = parserRun.parse_tag_2a(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_2c

var result = parserRun.parse_tag_2c(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_3a

var result = parserRun.parse_tag_3a(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_3c

var result = parserRun.parse_tag_3c(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_4a

var result = parserRun.parse_tag_4a(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_4c

var result = parserRun.parse_tag_4c(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_K

var result = parserRun.parse_tag_K(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_a

var result = parserRun.parse_tag_a(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_alpha

var result = parserRun.parse_tag_alpha(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_an

var result = parserRun.parse_tag_an(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_b

var result = parserRun.parse_tag_b(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_be

var result = parserRun.parse_tag_be(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_blur

var result = parserRun.parse_tag_blur(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_bord

var result = parserRun.parse_tag_bord(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_c

var result = parserRun.parse_tag_c(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_clip

var result = parserRun.parse_tag_clip(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fad

var result = parserRun.parse_tag_fad(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fade

var result = parserRun.parse_tag_fade(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fax

var result = parserRun.parse_tag_fax(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fay

var result = parserRun.parse_tag_fay(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fn

var result = parserRun.parse_tag_fn(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fr

var result = parserRun.parse_tag_fr(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_frx

var result = parserRun.parse_tag_frx(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fry

var result = parserRun.parse_tag_fry(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_frz

var result = parserRun.parse_tag_frz(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fs

var result = parserRun.parse_tag_fs(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fscx

var result = parserRun.parse_tag_fscx(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fscy

var result = parserRun.parse_tag_fscy(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fsminus

var result = parserRun.parse_tag_fsminus(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fsp

var result = parserRun.parse_tag_fsp(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_fsplus

var result = parserRun.parse_tag_fsplus(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_i

var result = parserRun.parse_tag_i(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_iclip

var result = parserRun.parse_tag_iclip(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_k

var result = parserRun.parse_tag_k(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_kf

var result = parserRun.parse_tag_kf(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_ko

var result = parserRun.parse_tag_ko(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_move

var result = parserRun.parse_tag_move(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_org

var result = parserRun.parse_tag_org(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_p

var result = parserRun.parse_tag_p(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_pbo

var result = parserRun.parse_tag_pbo(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_pos

var result = parserRun.parse_tag_pos(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_q

var result = parserRun.parse_tag_q(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_r

var result = parserRun.parse_tag_r(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_s

var result = parserRun.parse_tag_s(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_shad

var result = parserRun.parse_tag_shad(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_t

var result = parserRun.parse_tag_t(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_u

var result = parserRun.parse_tag_u(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_xbord

var result = parserRun.parse_tag_xbord(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_xshad

var result = parserRun.parse_tag_xshad(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_ybord

var result = parserRun.parse_tag_ybord(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_tag_yshad

var result = parserRun.parse_tag_yshad(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_text

var result = parserRun.parse_text(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
parse_unsignedDecimal

var result = parserRun.parse_unsignedDecimal(parent);
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
read

var result = parserRun.read(parent, next);
parent
!libjass.parser.ParseNode
next
string
Returns
libjass.parser.ParseNode
_haveMore

var result = parserRun._haveMore();
Returns
boolean
_parse_tag_clip_or_iclip

var result = parserRun._parse_tag_clip_or_iclip(tagName, parent);
tagName
string
One of "clip" and "iclip"
parent
!libjass.parser.ParseNode
Returns
libjass.parser.ParseNode
_peek

var result = parserRun._peek(count);
count
number=1
Returns
string

libjass.parts

Interfaces

interface Part

The base interface of the ASS tag classes.

Classes

class Alignment

An alignment tag {\an} or {\a}

var alignment = new libjass.parts.Alignment(value);
value
number
{\an###} -> alignment (number)
value
Getter

The value of this alignment tag.

var result = alignment.value;
?number
class Alpha

An alpha tag {\alpha}

var alpha = new libjass.parts.Alpha(value);
value
?number
{\alpha###} -> alpha (number), {\alpha} -> null
value
Getter

The value of this alpha tag.

var result = alpha.value;
?number
class Blur

A blur tag {\be}

var blur = new libjass.parts.Blur(value);
value
?number
{\be###} -> strength (number), {\be} -> null
value
Getter

The value of this blur tag.

var result = blur.value;
?number
class Bold

A bold tag {\b}

var bold = new libjass.parts.Bold(value);
value
*
{\b1} -> true, {\b0} -> false, {\b###} -> weight of the bold (number), {\b} -> null
value
Getter

The value of this bold tag.

var result = bold.value;
?boolean|?number
class Border

A border tag {\bord}

var border = new libjass.parts.Border(value);
value
?number
{\bord###} -> width (number), {\bord} -> null
value
Getter

The value of this border tag.

var result = border.value;
?number
class BorderX

A horizontal border tag {\xbord}

var borderX = new libjass.parts.BorderX(value);
value
?number
{\xbord###} -> width (number), {\xbord} -> null
value
Getter

The value of this horizontal border tag.

var result = borderX.value;
?number
class BorderY

A vertical border tag {\ybord}

var borderY = new libjass.parts.BorderY(value);
value
?number
{\ybord###} -> height (number), {\ybord} -> null
value
Getter

The value of this vertical border tag.

var result = borderY.value;
?number
class Color

Represents a CSS color with red, green, blue and alpha components. Instances of this class are immutable.

var color = new libjass.parts.Color(red, green, blue, alpha);
red
number
green
number
blue
number
alpha
number=1
alpha
Getter

The alpha component of this color as a number between 0 and 1, where 0 means transparent and 1 means opaque.

var result = color.alpha;
number
blue
Getter

The blue component of this color as a number between 0 and 255.

var result = color.blue;
number
green
Getter

The green component of this color as a number between 0 and 255.

var result = color.green;
number
red
Getter

The red component of this color as a number between 0 and 255.

var result = color.red;
number
toString

var result = color.toString();
Returns
string
The CSS representation "rgba(...)" of this color.
withAlpha

var result = color.withAlpha(value);
value
?number
The new alpha. If null, the existing alpha is used.
Returns
!libjass.parts.Color
Returns a new Color instance with the same color but the provided alpha.
class ColorKaraoke

A color karaoke tag {\k}

var colorKaraoke = new libjass.parts.ColorKaraoke(duration);
duration
number
{\k###} -> duration (number)
duration
Getter

The duration of this color karaoke tag.

var result = colorKaraoke.duration;
number
class Comment

A comment, i.e., any text enclosed in {} that is not understood as an ASS tag.

var comment = new libjass.parts.Comment(value);
value
string
The text of this comment
value
Getter

The value of this comment.

var result = comment.value;
string
class ComplexFade

A complex fade tag {\fade}

var complexFade = new libjass.parts.ComplexFade(a1, a2, a3, t1, t2, t3, t4);
a1
number
a2
number
a3
number
t1
number
t2
number
t3
number
t4
number
a1
Getter

The alpha value of this complex fade tag at time t2.

var result = complexFade.a1;
number
a2
Getter

The alpha value of this complex fade tag at time t3.

var result = complexFade.a2;
number
a3
Getter

The alpha value of this complex fade tag at time t4.

var result = complexFade.a3;
number
t1
Getter

The starting time of this complex fade tag.

var result = complexFade.t1;
number
t2
Getter

The first intermediate time of this complex fade tag.

var result = complexFade.t2;
number
t3
Getter

The second intermediate time of this complex fade tag.

var result = complexFade.t3;
number
t4
Getter

The ending time of this complex fade tag.

var result = complexFade.t4;
number
class DrawingBaselineOffset

A drawing mode baseline offset tag {\pbo}

var drawingBaselineOffset = new libjass.parts.DrawingBaselineOffset(value);
value
number
value
Getter

The value of this drawing mode baseline offset tag.

var result = drawingBaselineOffset.value;
number
class DrawingInstructions

A pseudo-part representing text interpreted as drawing instructions

var drawingInstructions = new libjass.parts.DrawingInstructions(instructions);
instructions
!Array.<!libjass.parts.drawing.Instruction>
instructions
Getter

The instructions contained in this drawing instructions part.

var result = drawingInstructions.instructions;
!Array.<!libjass.parts.drawing.Instruction>
class DrawingMode

A drawing mode tag {\p}

var drawingMode = new libjass.parts.DrawingMode(scale);
scale
number
scale
Getter

The scale of this drawing mode tag.

var result = drawingMode.scale;
number
class Fade

A simple fade tag {\fad}

var fade = new libjass.parts.Fade(start, end);
start
number
end
number
end
Getter

The end time of this fade tag.

var result = fade.end;
number
start
Getter

The start time of this fade tag.

var result = fade.start;
number
class FontName

A font name tag {\fn}

var fontName = new libjass.parts.FontName(value);
value
?string
{\fn###} -> name (string), {\fn} -> null
value
Getter

The value of this font name tag.

var result = fontName.value;
?string
class FontScaleX

A horizontal font scaling tag {\fscx}

var fontScaleX = new libjass.parts.FontScaleX(value);
value
?number
{\fscx###} -> scale (number), {\fscx} -> null
value
Getter

The value of this horizontal font scaling tag.

var result = fontScaleX.value;
?number
class FontScaleY

A vertical font scaling tag {\fscy}

var fontScaleY = new libjass.parts.FontScaleY(value);
value
?number
{\fscy###} -> scale (number), {\fscy} -> null
value
Getter

The value of this vertical font scaling tag.

var result = fontScaleY.value;
?number
class FontSize

A font size tag {\fs}

var fontSize = new libjass.parts.FontSize(value);
value
?number
{\fs###} -> size (number), {\fs} -> null
value
Getter

The value of this font size tag.

var result = fontSize.value;
?number
class FontSizeMinus

A font size decrease tag {\fs-}

var fontSizeMinus = new libjass.parts.FontSizeMinus(value);
value
?number
{\fs-###} -> difference (number)
value
Getter

The value of this font size decrease tag.

var result = fontSizeMinus.value;
?number
class FontSizePlus

A font size increase tag {\fs+}

var fontSizePlus = new libjass.parts.FontSizePlus(value);
value
?number
{\fs+###} -> difference (number)
value
Getter

The value of this font size increase tag.

var result = fontSizePlus.value;
?number
class GaussianBlur

A Gaussian blur tag {\blur}

var gaussianBlur = new libjass.parts.GaussianBlur(value);
value
?number
{\blur###} -> strength (number), {\blur} -> null
value
Getter

The value of this Gaussian blur tag.

var result = gaussianBlur.value;
?number
class Italic

An italic tag {\i}

var italic = new libjass.parts.Italic(value);
value
?boolean
{\i1} -> true, {\i0} -> false, {\i} -> null
value
Getter

The value of this italic tag.

var result = italic.value;
?boolean
class LetterSpacing

A letter-spacing tag {\fsp}

var letterSpacing = new libjass.parts.LetterSpacing(value);
value
?number
{\fsp###} -> spacing (number), {\fsp} -> null
value
Getter

The value of this letter-spacing tag.

var result = letterSpacing.value;
?number
class Move

A movement tag {\move}

var move = new libjass.parts.Move(x1, y1, x2, y2, t1, t2);
x1
number
y1
number
x2
number
y2
number
t1
number
t2
number
t1
Getter

The start time of this move tag.

var result = move.t1;
number
t2
Getter

The end time value of this move tag.

var result = move.t2;
number
x1
Getter

The starting x value of this move tag.

var result = move.x1;
number
x2
Getter

The ending x value of this move tag.

var result = move.x2;
number
y1
Getter

The starting y value of this move tag.

var result = move.y1;
number
y2
Getter

The ending y value of this move tag.

var result = move.y2;
number
class NewLine

A newline character \N.

var newLine = new libjass.parts.NewLine();
class OutlineAlpha

An outline alpha tag {\3a}

var outlineAlpha = new libjass.parts.OutlineAlpha(value);
value
?number
{\3a###} -> alpha (number), {\3a} -> null
value
Getter

The value of this outline alpha tag.

var result = outlineAlpha.value;
?number
class OutlineColor

An outline color tag {\3c}

var outlineColor = new libjass.parts.OutlineColor(value);
value
libjass.parts.Color
{\3c###} -> color (Color), {\3c} -> null
value
Getter

The value of this outline color tag.

var result = outlineColor.value;
libjass.parts.Color
class OutlineKaraoke

An outline karaoke tag {\ko}

var outlineKaraoke = new libjass.parts.OutlineKaraoke(duration);
duration
number
{\ko###} -> duration (number)
duration
Getter

The duration of this outline karaoke tag.

var result = outlineKaraoke.duration;
number
class Position

A position tag {\pos}

var position = new libjass.parts.Position(x, y);
x
number
y
number
x
Getter

The x value of this position tag.

var result = position.x;
number
y
Getter

The y value of this position tag.

var result = position.y;
number
class PrimaryAlpha

A primary alpha tag {\1a}

var primaryAlpha = new libjass.parts.PrimaryAlpha(value);
value
?number
{\1a###} -> alpha (number), {\1a} -> null
value
Getter

The value of this primary alpha tag.

var result = primaryAlpha.value;
?number
class PrimaryColor

A primary color tag {\c} or {\1c}

var primaryColor = new libjass.parts.PrimaryColor(value);
value
libjass.parts.Color
{\1c###} -> color (Color), {\1c} -> null
value
Getter

The value of this primary color tag.

var result = primaryColor.value;
libjass.parts.Color
class RectangularClip

A rectangular clip tag {\clip} or {\iclip}

var rectangularClip = new libjass.parts.RectangularClip(x1, y1, x2, y2, inside);
x1
number
y1
number
x2
number
y2
number
inside
boolean
inside
Getter

Whether this rectangular clip tag clips the region it encloses or the region it excludes.

var result = rectangularClip.inside;
boolean
x1
Getter

The X coordinate of the starting position of this rectangular clip tag.

var result = rectangularClip.x1;
number
x2
Getter

The X coordinate of the ending position of this rectangular clip tag.

var result = rectangularClip.x2;
number
y1
Getter

The Y coordinate of the starting position of this rectangular clip tag.

var result = rectangularClip.y1;
number
y2
Getter

The Y coordinate of the ending position of this rectangular clip tag.

var result = rectangularClip.y2;
number
class Reset

A style reset tag {\r}

var reset = new libjass.parts.Reset(value);
value
?string
{\r###} -> style name (string), {\r} -> null
value
Getter

The value of this style reset tag.

var result = reset.value;
?string
class RotateX

An X-axis rotation tag {\frx}

var rotateX = new libjass.parts.RotateX(value);
value
?number
{\frx###} -> angle (number), {\frx} -> null
value
Getter

The value of this X-axis rotation tag.

var result = rotateX.value;
?number
class RotateY

A Y-axis rotation tag {\fry}

var rotateY = new libjass.parts.RotateY(value);
value
?number
{\fry###} -> angle (number), {\fry} -> null
value
Getter

The value of this Y-axis rotation tag.

var result = rotateY.value;
?number
class RotateZ

A Z-axis rotation tag {\fr} or {\frz}

var rotateZ = new libjass.parts.RotateZ(value);
value
?number
{\frz###} -> angle (number), {\frz} -> null
value
Getter

The value of this Z-axis rotation tag.

var result = rotateZ.value;
?number
class RotationOrigin

A rotation origin tag {\org}

var rotationOrigin = new libjass.parts.RotationOrigin(x, y);
x
number
y
number
x
Getter

The x value of this rotation origin tag.

var result = rotationOrigin.x;
number
y
Getter

The y value of this rotation origin tag.

var result = rotationOrigin.y;
number
class SecondaryAlpha

A secondary alpha tag {\2a}

var secondaryAlpha = new libjass.parts.SecondaryAlpha(value);
value
?number
{\2a###} -> alpha (number), {\2a} -> null
value
Getter

The value of this secondary alpha tag.

var result = secondaryAlpha.value;
?number
class SecondaryColor

A secondary color tag {\2c}

var secondaryColor = new libjass.parts.SecondaryColor(value);
value
libjass.parts.Color
{\2c###} -> color (Color), {\2c} -> null
value
Getter

The value of this secondary color tag.

var result = secondaryColor.value;
libjass.parts.Color
class Shadow

A shadow tag {\shad}

var shadow = new libjass.parts.Shadow(value);
value
?number
{\shad###} -> depth (number), {\shad} -> null
value
Getter

The value of this shadow tag.

var result = shadow.value;
?number
class ShadowAlpha

A shadow alpha tag {\4a}

var shadowAlpha = new libjass.parts.ShadowAlpha(value);
value
?number
{\4a###} -> alpha (number), {\4a} -> null
value
Getter

The value of this shadow alpha tag.

var result = shadowAlpha.value;
?number
class ShadowColor

A shadow color tag {\4c}

var shadowColor = new libjass.parts.ShadowColor(value);
value
libjass.parts.Color
{\4c###} -> color (Color), {\4c} -> null
value
Getter

The value of this shadow color tag.

var result = shadowColor.value;
libjass.parts.Color
class ShadowX

A horizontal shadow tag {\xshad}

var shadowX = new libjass.parts.ShadowX(value);
value
?number
{\xshad###} -> depth (number), {\xshad} -> null
value
Getter

The value of this horizontal shadow tag.

var result = shadowX.value;
?number
class ShadowY

A vertical shadow tag {\yshad}

var shadowY = new libjass.parts.ShadowY(value);
value
?number
{\yshad###} -> depth (number), {\yshad} -> null
value
Getter

The value of this vertical shadow tag.

var result = shadowY.value;
?number
class SkewX

An X-axis shearing tag {\fax}

var skewX = new libjass.parts.SkewX(value);
value
?number
{\fax###} -> angle (number), {\fax} -> null
value
Getter

The value of this X-axis shearing tag.

var result = skewX.value;
?number
class SkewY

A Y-axis shearing tag {\fay}

var skewY = new libjass.parts.SkewY(value);
value
?number
{\fay###} -> angle (number), {\fay} -> null
value
Getter

The value of this Y-axis shearing tag.

var result = skewY.value;
?number
class StrikeThrough

A strike-through tag {\s}

var strikeThrough = new libjass.parts.StrikeThrough(value);
value
?boolean
{\s1} -> true, {\s0} -> false, {\s} -> null
value
Getter

The value of this strike-through tag.

var result = strikeThrough.value;
?boolean
class SweepingColorKaraoke

A sweeping color karaoke tag {\K} or {\kf}

var sweepingColorKaraoke = new libjass.parts.SweepingColorKaraoke(duration);
duration
number
{\kf###} -> duration (number)
duration
Getter

The duration of this sweeping color karaoke tag.

var result = sweepingColorKaraoke.duration;
number
class Text

A block of text, i.e., any text not enclosed in {}. Also includes \h.

var text = new libjass.parts.Text(value);
value
string
The content of this block of text
value
Getter

The value of this text part.

var result = text.value;
string
toString

var result = text.toString();
Returns
string
class Transform

A transform tag {\t}

var transform = new libjass.parts.Transform(start, end, accel, tags);
start
number
end
number
accel
number
tags
!Array.<!libjass.parts.Tag>
accel
Getter

The acceleration of this transform tag.

var result = transform.accel;
number
end
Getter

The ending time of this transform tag.

var result = transform.end;
number
start
Getter

The starting time of this transform tag.

var result = transform.start;
number
tags
Getter

The tags animated by this transform tag.

var result = transform.tags;
!Array.<!libjass.parts.Tag>
class Underline

An underline tag {\u}

var underline = new libjass.parts.Underline(value);
value
?boolean
{\u1} -> true, {\u0} -> false, {\u} -> null
value
Getter

The value of this underline tag.

var result = underline.value;
?boolean
class VectorClip

A vector clip tag {\clip} or {\iclip}

var vectorClip = new libjass.parts.VectorClip(scale, instructions, inside);
scale
number
instructions
!Array.<!libjass.parts.drawing.Instruction>
inside
boolean
inside
Getter

Whether this vector clip tag clips the region it encloses or the region it excludes.

var result = vectorClip.inside;
boolean
instructions
Getter

The clip commands of this vector clip tag.

var result = vectorClip.instructions;
string
scale
Getter

The scale of this vector clip tag.

var result = vectorClip.scale;
number
class WrappingStyle

A wrapping style tag {\q}

var wrappingStyle = new libjass.parts.WrappingStyle(value);
value
number
{\q###} -> style (number)
value
Getter

The value of this wrapping style tag.

var result = wrappingStyle.value;
number

libjass.parts.drawing

Interfaces

interface Instruction

The base interface of the drawing instructions.

Classes

class CubicBezierCurveInstruction

An instruction to draw a cubic bezier curve to a particular position, with two given control points.

var cubicBezierCurveInstruction = new libjass.parts.drawing.CubicBezierCurveInstruction(x1, y1, x2, y2, x3, y3);
x1
number
y1
number
x2
number
y2
number
x3
number
y3
number
x1
Getter

The X position of the first control point of this cubic bezier curve instruction.

var result = cubicBezierCurveInstruction.x1;
number
x2
Getter

The X position of the second control point of this cubic bezier curve instruction.

var result = cubicBezierCurveInstruction.x2;
number
x3
Getter

The ending X position of this cubic bezier curve instruction.

var result = cubicBezierCurveInstruction.x3;
number
y1
Getter

The Y position of the first control point of this cubic bezier curve instruction.

var result = cubicBezierCurveInstruction.y1;
number
y2
Getter

The Y position of the second control point of this cubic bezier curve instruction.

var result = cubicBezierCurveInstruction.y2;
number
y3
Getter

The ending Y position of this cubic bezier curve instruction.

var result = cubicBezierCurveInstruction.y3;
number
class LineInstruction

An instruction to draw a line to a particular position.

var lineInstruction = new libjass.parts.drawing.LineInstruction(x, y);
x
number
y
number
x
Getter

The X position of this line instruction.

var result = lineInstruction.x;
number
y
Getter

The Y position of this line instruction.

var result = lineInstruction.y;
number
class MoveInstruction

An instruction to move to a particular position.

var moveInstruction = new libjass.parts.drawing.MoveInstruction(x, y);
x
number
y
number
x
Getter

The X position of this move instruction.

var result = moveInstruction.x;
number
y
Getter

The Y position of this move instruction.

var result = moveInstruction.y;
number

libjass.renderers

Interfaces

interface Clock extends EventSource.<ClockEvent>

The clock interface. A clock is used by a renderer as a source of libjass.renderers.ClockEvents.

currentTime

var result = clock.currentTime;
clock.currentTime = value;
number
enabled

var result = clock.enabled;
clock.enabled = value;
boolean
rate

Gets the rate of the clock - how fast the clock ticks compared to real time.

var result = clock.rate;
clock.rate = value;
number
addEventListener

clock.addEventListener(type, listener);
type
number
listener
!Function
disable

Disable the clock.

var result = clock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable

Enable the clock.

var result = clock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
setEnabled

Enable or disable the clock.

var result = clock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
toggle

Toggle the clock.

clock.toggle();

Classes

class DefaultRenderer extends WebRenderer

A default renderer implementation.

var defaultRenderer = new libjass.renderers.DefaultRenderer(video, ass, settings);
video
!HTMLVideoElement
ass
!libjass.ASS
settings
libjass.renderers.RendererSettings
resizeVideo

@deprecated

defaultRenderer.resizeVideo(width, height);
width
number
height
number
_ready

defaultRenderer._ready();
_onFullScreenChange

defaultRenderer._onFullScreenChange(fullScreenElement);
fullScreenElement
!Element
class EventSource.<T>

A mixin class that represents an event source.

var eventSource = new libjass.renderers.EventSource();
_eventListeners

A map from event type to an array of all the listeners registered for that event type.

var result = eventSource._eventListeners;
eventSource._eventListeners = value;
!Map.<T, !Array.<Function>>
_dispatchEvent

Calls all listeners registered for the given event type.

eventSource._dispatchEvent(type, args);
type
!T
The type of event to dispatch
args
!Array.<*>
Arguments for the listeners of the event
addEventListener

Add a listener for the given event.

eventSource.addEventListener(type, listener);
type
!T
The type of event to attach the listener for
listener
!Function
The listener
class ManualClock

An implementation of libjass.renderers.Clock that allows user script to manually trigger play, pause and timeUpdate events.

var manualClock = new libjass.renderers.ManualClock();
_dispatchEvent

var result = manualClock._dispatchEvent;
manualClock._dispatchEvent = value;
function(number, Array.<*>)
_eventListeners

var result = manualClock._eventListeners;
manualClock._eventListeners = value;
!Map.<T, !Array.<Function>>
addEventListener

var result = manualClock.addEventListener;
manualClock.addEventListener = value;
function(number, !Function)
currentTime
Getter

var result = manualClock.currentTime;
number
enabled
Getter

var result = manualClock.enabled;
boolean
rate
Getter

Gets the rate of the clock - how fast the clock ticks compared to real time.

var result = manualClock.rate;
number
disable

Disable the clock.

var result = manualClock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable

Enable the clock.

var result = manualClock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
pause

Trigger a libjass.renderers.ClockEvent.Pause

manualClock.pause();
play

Trigger a libjass.renderers.ClockEvent.Play

manualClock.play();
setEnabled

Enable or disable the clock.

var result = manualClock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
setRate

Sets the rate of the clock - how fast the clock ticks compared to real time.

manualClock.setRate(rate);
rate
number
The new rate of the clock.
stop

Trigger a libjass.renderers.ClockEvent.Stop

manualClock.stop();
tick

Trigger a libjass.renderers.ClockEvent.Tick

manualClock.tick(currentTime);
currentTime
number
toggle

Toggle the clock.

manualClock.toggle();
class NullRenderer

A renderer implementation that doesn't output anything.

var nullRenderer = new libjass.renderers.NullRenderer(ass, clock, settings);
ass
!libjass.ASS
clock
!libjass.renderers.Clock
settings
libjass.renderers.RendererSettings
ass
Getter

var result = nullRenderer.ass;
!libjass.ASS
clock
Getter

var result = nullRenderer.clock;
!libjass.renderers.Clock
enabled
Getter

var result = nullRenderer.enabled;
boolean
id
Getter

The unique ID of this renderer. Auto-generated.

var result = nullRenderer.id;
number
settings
Getter

var result = nullRenderer.settings;
!libjass.renderers.RendererSettings
disable

Disable the renderer.

var result = nullRenderer.disable();
Returns
boolean
True if the renderer is now disabled, false if it was already disabled.
draw

Draw a dialogue. This is a no-op for this type.

nullRenderer.draw(dialogue);
dialogue
!libjass.Dialogue
enable

Enable the renderer.

var result = nullRenderer.enable();
Returns
boolean
True if the renderer is now enabled, false if it was already enabled.
preRender

Pre-render a dialogue. This is a no-op for this type.

nullRenderer.preRender(dialogue);
dialogue
!libjass.Dialogue
setEnabled

Enable or disable the renderer.

var result = nullRenderer.setEnabled(enabled);
enabled
boolean
If true, the renderer is enabled, otherwise it's disabled.
Returns
boolean
True if the renderer is now in the given state, false if it was already in that state.
toggle

Toggle the renderer.

nullRenderer.toggle();
_onClockPause

Runs when the clock is paused.

nullRenderer._onClockPause();
_onClockPlay

Runs when the clock is enabled, or starts playing, or is resumed from pause.

nullRenderer._onClockPlay();
_onClockRateChange

Runs when the clock changes its rate.

nullRenderer._onClockRateChange();
_onClockStop

Runs when the clock is disabled.

nullRenderer._onClockStop();
_onClockTick

Runs when the clock's current time changed. This might be a result of either regular playback or seeking.

nullRenderer._onClockTick();
class RendererSettings

Settings for the renderer.

var rendererSettings = new libjass.renderers.RendererSettings();
fontMap

A map of font name to one or more URLs of that font. If provided, the fonts in this map are pre-loaded by the WebRenderer when it's created. If you have a <style> or <link> element on the page containing @font-face rules, you can use the libjass.renderers.RendererSettings.makeFontMapFromStyleElement convenience method to create a font map.

var result = rendererSettings.fontMap;
rendererSettings.fontMap = value;
!Map.<string, !Array.<string>>
preRenderTime

Subtitles will be pre-rendered for this amount of time (seconds). Defaults to 5.

var result = rendererSettings.preRenderTime;
rendererSettings.preRenderTime = value;
number
preciseOutlines

Subtitle outlines will be rendered in full detail. When false, the value of blur is used to draw less outlines for better performance and (hopefully) similar output. Defaults to false.

var result = rendererSettings.preciseOutlines;
rendererSettings.preciseOutlines = value;
boolean
from

Converts an arbitrary object into a libjass.renderers.RendererSettings object.

var result = libjass.renderers.RendererSettings.from(object);
object
*
Returns
!libjass.renderers.RendererSettings
makeFontMapFromStyleElement

A convenience method to create a font map from a <style> or <link> element that contains @font-face rules.

var result = libjass.renderers.RendererSettings.makeFontMapFromStyleElement(linkStyle);
linkStyle
!LinkStyle
Returns
!Map.<string, !Array.<string>>
_from

var result = libjass.renderers.RendererSettings._from(fontMap, preRenderTime, preciseOutlines);
fontMap
Map.<string, !Array.<string>>=null
preRenderTime
number=5
preciseOutlines
boolean=false
Returns
!libjass.renderers.RendererSettings
_stripQuotes

var result = libjass.renderers.RendererSettings._stripQuotes(str);
str
string
Returns
string
class VideoClock

An implementation of libjass.renderers.Clock that generates play, pause and timeUpdate events according to the state of a <video> element.

var videoClock = new libjass.renderers.VideoClock(video);
video
!HTMLVideoElement
_dispatchEvent

var result = videoClock._dispatchEvent;
videoClock._dispatchEvent = value;
function(number, Array.<*>)
_eventListeners

var result = videoClock._eventListeners;
videoClock._eventListeners = value;
!Map.<T, !Array.<Function>>
addEventListener

var result = videoClock.addEventListener;
videoClock.addEventListener = value;
function(number, !Function)
currentTime
Getter

var result = videoClock.currentTime;
number
enabled
Getter

var result = videoClock.enabled;
boolean
rate
Getter

Gets the rate of the clock - how fast the clock ticks compared to real time.

var result = videoClock.rate;
number
disable

Disable the clock.

var result = videoClock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable

Enable the clock.

var result = videoClock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
setEnabled

Enable or disable the clock.

var result = videoClock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
toggle

Toggle the clock.

videoClock.toggle();
_onTimerTick

videoClock._onTimerTick();
_onVideoPause

videoClock._onVideoPause();
_onVideoPlaying

videoClock._onVideoPlaying();
_onVideoRateChange

videoClock._onVideoRateChange();
_onVideoSeeking

videoClock._onVideoSeeking();
_startTicking

videoClock._startTicking();
_stopTicking

videoClock._stopTicking();
class WebRenderer extends NullRenderer

A renderer implementation that draws subtitles to the given <div>

var webRenderer = new libjass.renderers.WebRenderer(ass, clock, libjassSubsWrapper, settings);
ass
!libjass.ASS
clock
!libjass.renderers.Clock
libjassSubsWrapper
!HTMLDivElement
Subtitles will be rendered to this <div>
settings
!libjass.renderers.RendererSettings
_dispatchEvent

var result = webRenderer._dispatchEvent;
webRenderer._dispatchEvent = value;
function(number, Array.<*>)
_eventListeners

var result = webRenderer._eventListeners;
webRenderer._eventListeners = value;
!Map.<T, !Array.<Function>>
addEventListener

var result = webRenderer.addEventListener;
webRenderer.addEventListener = value;
function(number, !Function)
libjassSubsWrapper
Getter

var result = webRenderer.libjassSubsWrapper;
!HTMLDivElement
draw

Returns the subtitle div for display. The libjass.renderers.WebRenderer.currentTime is used to shift the animations appropriately, so that at the time the div is inserted into the DOM and the animations begin, they are in sync with the clock time.

webRenderer.draw(dialogue);
dialogue
!libjass.Dialogue
preRender

The magic happens here. The subtitle div is rendered and stored. Call libjass.renderers.WebRenderer.draw to get a clone of the div to display.

webRenderer.preRender(dialogue);
dialogue
!libjass.Dialogue
resize

Resize the subtitles to the given new dimensions.

webRenderer.resize(width, height);
width
number
height
number
_onClockPause

webRenderer._onClockPause();
_onClockPlay

webRenderer._onClockPlay();
_onClockRateChange

webRenderer._onClockRateChange();
_onClockStop

webRenderer._onClockStop();
_onClockTick

webRenderer._onClockTick();
_ready

webRenderer._ready();
_removeAllSubs

webRenderer._removeAllSubs();
_removeSub

webRenderer._removeSub(sub);
sub
!HTMLDivElement
class AnimationCollection

This class represents a collection of animations. Each animation contains one or more keyframes. The collection can then be converted to a CSS3 representation.

var animationCollection = new AnimationCollection(renderer, dialogue);
renderer
!libjass.renderers.NullRenderer
The renderer that this collection is associated with
dialogue
!libjass.Dialogue
The Dialogue that this collection is associated with
animationDelays
Getter

This array should be used to set the "animation-delay" CSS property of the target element.

var result = animationCollection.animationDelays;
!Array.<number>
animationStyle
Getter

This string should be set as the "animation" CSS property of the target element.

var result = animationCollection.animationStyle;
string
cssText
Getter

This string contains the animation definitions and should be inserted into a <style> element.

var result = animationCollection.cssText;
string
add

Add an animation to this collection. The given keyframes together make one animation.

animationCollection.add(timingFunction, keyframes);
timingFunction
string
One of the acceptable values for the "animation-timing-function" CSS property
keyframes
Array.<!{time: number, properties: !Object.<string, string>}>
class DrawingStyles

This class represents an ASS drawing - a set of drawing instructions between {\p} tags.

var drawingStyles = new DrawingStyles(outputScaleX, outputScaleY);
outputScaleX
number
outputScaleY
number
baselineOffset
Setter

drawingStyles.baselineOffset = value;
value
number
scale
Setter

drawingStyles.scale = value;
value
number
toSVG

Converts this drawing to an <svg> element.

var result = drawingStyles.toSVG(drawingInstructions, fillColor);
drawingInstructions
!libjass.parts.DrawingInstructions
fillColor
!libjass.parts.Color
Returns
!SVGSVGElement
class Keyframe

This class represents a single keyframe. It has a list of CSS properties (names and values) associated with a point in time. Multiple keyframes make up an animation.

var keyframe = new Keyframe(time, properties);
time
number
properties
!Object.<string, string>
properties
Getter

var result = keyframe.properties;
!Object.<string, string>
time
Getter

var result = keyframe.time;
number
class SpanStyles

This class represents the style attribute of a span. As a Dialogue's div is rendered, individual parts are added to span's, and this class is used to maintain the style attribute of those.

var spanStyles = new SpanStyles(renderer, dialogue, scaleX, scaleY, settings, fontSizeElement, svgDefsElement);
renderer
!libjass.renderers.NullRenderer
The renderer that this set of styles is associated with
dialogue
!libjass.Dialogue
The Dialogue that this set of styles is associated with
scaleX
number
The horizontal scaling of the subtitles
scaleY
number
The vertical scaling of the subtitles
settings
!libjass.renderers.RendererSettings
The renderer settings
fontSizeElement
!HTMLDivElement
A <div> element to measure font sizes with
svgDefsElement
!SVGDefsElement
An SVG <defs> element to append filter definitions to
blur
Setter

Sets the blur property. null defaults it to 0.

spanStyles.blur = value;
value
?number
bold
Setter

Sets the bold property. null defaults it to the default style's value.

spanStyles.bold = value;
value
(?number|?boolean)
fontName
Setter

Sets the font name property. null defaults it to the default style's value.

spanStyles.fontName = value;
value
?string
fontScaleX
Setter

Sets the horizontal font scaling property. null defaults it to the default style's value.

spanStyles.fontScaleX = value;
value
?number
fontScaleY
Setter

Sets the vertical font scaling property. null defaults it to the default style's value.

spanStyles.fontScaleY = value;
value
?number
fontSize
Setter

Sets the font size property. null defaults it to the default style's value.

spanStyles.fontSize = value;
value
?number
gaussianBlur
Setter

Sets the Gaussian blur property. null defaults it to 0.

spanStyles.gaussianBlur = value;
value
?number
italic
Setter

Sets the italic property. null defaults it to the default style's value.

spanStyles.italic = value;
value
?boolean
letterSpacing
Setter

Sets the letter spacing property. null defaults it to the default style's value.

spanStyles.letterSpacing = value;
value
?number
outlineAlpha
Setter

Sets the outline alpha property.

spanStyles.outlineAlpha = value;
value
?number
outlineColor
Setter

Sets the outline color property. null defaults it to the default style's value.

spanStyles.outlineColor = value;
value
libjass.parts.Color
outlineHeight
Setter

Sets the outline height property. null defaults it to the style's original outline height value.

spanStyles.outlineHeight = value;
value
?number
outlineWidth
Setter

Sets the outline width property. null defaults it to the style's original outline width value.

spanStyles.outlineWidth = value;
value
?number
primaryAlpha
Getter

Gets the primary alpha property.

var result = spanStyles.primaryAlpha;
?number
Setter

Sets the primary alpha property.

spanStyles.primaryAlpha = value;
value
?number
primaryColor
Getter

Gets the primary color property.

var result = spanStyles.primaryColor;
!libjass.parts.Color
Setter

Sets the primary color property. null defaults it to the default style's value.

spanStyles.primaryColor = value;
value
libjass.parts.Color
rotationX
Setter

Sets the X-axis rotation property.

spanStyles.rotationX = value;
value
?number
rotationY
Setter

Sets the Y-axis rotation property.

spanStyles.rotationY = value;
value
?number
rotationZ
Setter

Sets the Z-axis rotation property.

spanStyles.rotationZ = value;
value
?number
secondaryAlpha
Setter

Sets the secondary alpha property.

spanStyles.secondaryAlpha = value;
value
?number
secondaryColor
Setter

Sets the secondary color property. null defaults it to the default style's value.

spanStyles.secondaryColor = value;
value
libjass.parts.Color
shadowAlpha
Setter

Sets the shadow alpha property.

spanStyles.shadowAlpha = value;
value
?number
shadowColor
Setter

Sets the shadow color property. null defaults it to the default style's value.

spanStyles.shadowColor = value;
value
libjass.parts.Color
shadowDepthX
Setter

Sets the outline width property. null defaults it to the style's original shadow depth X value.

spanStyles.shadowDepthX = value;
value
?number
shadowDepthY
Setter

Sets the shadow height property. null defaults it to the style's original shadow depth Y value.

spanStyles.shadowDepthY = value;
value
?number
skewX
Setter

Sets the X-axis skew property.

spanStyles.skewX = value;
value
?number
skewY
Setter

Sets the Y-axis skew property.

spanStyles.skewY = value;
value
?number
strikeThrough
Setter

Sets the strike-through property. null defaults it to the default style's value.

spanStyles.strikeThrough = value;
value
?boolean
underline
Setter

Sets the underline property. null defaults it to the default style's value.

spanStyles.underline = value;
value
?boolean
reset

Resets the styles to the defaults provided by the argument.

spanStyles.reset(newStyle);
newStyle
libjass.Style
The new defaults to reset the style to. If null, the styles are reset to the default style of the Dialogue.
setStylesOnSpan

Sets the style attribute on the given span element.

var result = spanStyles.setStylesOnSpan(span);
span
!HTMLSpanElement
Returns
!HTMLSpanElement
The resulting <span> with the CSS styles applied. This may be a wrapper around the input <span> if the styles were applied using SVG filters.
_getFontSize

var result = SpanStyles._getFontSize(fontFamily, lineHeight, fontSizeElement);
fontFamily
string
lineHeight
number
fontSizeElement
!HTMLDivElement
Returns
number

Enums

enum ClockEvent

The type of clock event.

Play = 0

Tick = 1

Pause = 2

Stop = 3

RateChange = 4

enum VideoState

The state of the video.

Playing = 0

Paused = 1

libjass.webworker

Free functions

_registerClassPrototype

Registers a prototype as a deserializable type.

libjass.webworker._registerClassPrototype(prototype);
prototype
!*
_registerWorkerCommand

Registers a handler for the given worker command.

libjass.webworker._registerWorkerCommand(command, handler);
command
number
The command that this handler will handle. One of the libjass.webworker.WorkerCommands constants.
handler
function(*, function(*, *))
The handler. A function of the form (parameters: *, response: function(error: *, result: *): void): void
createWorker

Create a new web worker and returns a libjass.webworker.WorkerChannel to it.

var result = libjass.webworker.createWorker(scriptPath);
scriptPath
string=
The path to libjass.js to be loaded in the web worker. If the browser supports document.currentScript, the parameter is optional and, if not provided, the path will be determined from the src attribute of the <script> element that contains the currently running copy of libjass.js
Returns
!libjass.webworker.WorkerChannel
A communication channel to the new web worker.

Interfaces

interface WorkerChannel

Represents a communication channel between the host and the web worker. An instance of this class is created by calling libjass.webworker.createWorker

request

Sends a request to the other side to execute the given command with the given parameters.

var result = workerChannel.request(command, parameters);
command
number
parameters
*
Returns
!Promise.<*>
A promise that will get resolved when the other side computes the result
interface WorkerCommandHandler

The signature of a handler registered to handle a particular command in libjass.webworker.WorkerCommands

interface WorkerResultCallback

The signature of a callback called by a libjass.webworker.WorkerCommandHandler to report its result back to the caller.

interface WorkerCommunication

The interface implemented by a communication channel to the other side.

addEventListener

workerCommunication.addEventListener(type, listener, useCapture);
type
"message"
listener
function(!MessageEvent): *
useCapture
?boolean
addEventListener

workerCommunication.addEventListener(type, listener, useCapture);
type
string
listener
!EventListener
useCapture
?boolean
postMessage

workerCommunication.postMessage(message);
message
*
interface WorkerRequestMessage

The interface implemented by a request sent to the other side of the communication channel.

command

The command type of this request.

var result = workerRequestMessage.command;
workerRequestMessage.command = value;
number
parameters

Any parameters serialized with this request.

var result = workerRequestMessage.parameters;
workerRequestMessage.parameters = value;
*
requestId

An internal identifier for this request. Used to connect responses to their corresponding requests.

var result = workerRequestMessage.requestId;
workerRequestMessage.requestId = value;
number
interface WorkerResponseMessage

The interface implemented by a response received from the other side of the communication channel.

error

Set if the computation of this response resulted in an error.

var result = workerResponseMessage.error;
workerResponseMessage.error = value;
*
requestId

An internal identifier for this response. Used to connect responses to their corresponding requests.

var result = workerResponseMessage.requestId;
workerResponseMessage.requestId = value;
number
result

The result of computing this response.

var result = workerResponseMessage.result;
workerResponseMessage.result = value;
*

Classes

class WorkerChannelImpl

Internal implementation of libjass.webworker.WorkerChannel

var workerChannelImpl = new WorkerChannelImpl(comm);
comm
!*
The other side of the channel. When created by the host, this is the web worker. When created by the web worker, this is its global object.
cancelRequest

workerChannelImpl.cancelRequest(requestId);
requestId
number
request

var result = workerChannelImpl.request(command, parameters);
command
number
parameters
*
Returns
!Promise.<*>
_fromJSON

var result = WorkerChannelImpl._fromJSON(str);
str
string
Returns
*
_onMessage

workerChannelImpl._onMessage(rawMessage);
rawMessage
string
_respond

workerChannelImpl._respond(message);
message
!WorkerResponseMessage
_toJSON

var result = WorkerChannelImpl._toJSON(obj);
obj
*
Returns
string

Enums

enum WorkerCommands

The commands that can be sent to or from a web worker.

Response = 0

Parse = 1