Namespace libjass

Properties

debugMode
Getter
Debug mode. When true, libjass logs some debug messages.
var result = libjass.debugMode;
boolean
Map
Getter

Set to the global implementation of Map if the environment has one, else set to ./utility/map.SimpleMap

Can be set to a value using libjass.configure

Set it to null to force ./utility/map.SimpleMap to be used even if a global Map is present.

var result = libjass.Map;
function(new:Map, !Array.<!Array.<*>>=)
Promise
Getter

Set to the global implementation of Promise if the environment has one, else set to ./utility/promise.SimplePromise

Can be set to a value using libjass.configure

Set it to null to force ./utility/promise.SimplePromise to be used even if a global Promise is present.

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

Set to the global implementation of Set if the environment has one, else set to ./utility/set.SimpleSet

Can be set to a value using libjass.configure

Set it to null to force ./utility/set.SimpleSet to be used even if a global Set is present.

var result = libjass.Set;
function(new:Set, !Array.<T>=)
verboseMode
Getter
Verbose debug mode. When true, libjass logs some more debug messages. This setting is independent of libjass.debugMode
var result = libjass.verboseMode;
boolean
version
Getter

The version of libjass. An array like

["0.12.0", 0, 12, 0]

var result = libjass.version;
!Array.<string|number>

Free functions

configure
Configures libjass with the given properties.
libjass.configure(newConfig);
newConfig
!*
"debugMode"
?boolean
When true, libjass logs some debug messages.
"verboseMode"
?boolean
When true, libjass logs some more debug messages. This setting is independent of libjass.debugMode
"Set"
?function(new:Set, !Array.<T>=)
Sets the Set implementation used by libjass to the provided one. If null, ./utility/set.SimpleSet is used.
"Map"
?function(new:Map, !Array.<!Array.<*>>=)
Sets the Map implementation used by libjass to the provided one. If null, ./utility/map.SimpleMap is used.
"Promise"
?function(new:Promise)
Sets the Promise implementation used by libjass to the provided one. If null, ./utility/promise.SimplePromise is used.
deserialize
var result = libjass.deserialize(str);
str
string
Returns
*
serialize
Serializes the given object.
var result = libjass.serialize(obj);
obj
*
Returns
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();
attachments
Getter
The attachments of this script.
var result = ass.attachments;
!Array.<!libjass.Attachment>
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>
addAttachment
Add an attachment to this ASS script.
ass.addAttachment(attachment);
attachment
!libjass.Attachment
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.
fromJSON
Custom deserialization for ASS objects.
var result = libjass.ASS.fromJSON(obj);
obj
!*
Returns
!libjass.ASS
fromReadableStream
Creates an ASS object from the given ReadableStream.
var result = libjass.ASS.fromReadableStream(stream, encoding, type);
stream
!ReadableStream
encoding
string="utf-8"
type
(number|string)=0
The type of the script. One of the libjass.Format constants, or one of the strings "ass" and "srt".
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
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|string)=0
The type of the script. One of the libjass.Format constants, or one of the strings "ass" and "srt".
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|string)=0
The type of the script. One of the libjass.Format constants, or one of the strings "ass" and "srt".
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|string)=0
The type of the script. One of the libjass.Format constants, or one of the strings "ass" and "srt".
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
toJSON
Custom JSON serialization for ASS objects.
var result = ass.toJSON();
Returns
!*
class Attachment
This class represents an attachment in a libjass.ASS script.
var attachment = new libjass.Attachment(filename, type);
filename
string
The filename of this attachment.
type
number
The type of this attachment.
contents
Getter
The contents of this attachment in base64 encoding.
var result = attachment.contents;
number
Setter
The contents of this attachment in base64 encoding.
attachment.contents = value;
value
number
filename
Getter
The filename of this attachment.
var result = attachment.filename;
number
type
Getter
The type of this attachment.
var result = attachment.type;
number
class DeferredPromise.<T>
A deferred promise.
var deferredPromise = new libjass.DeferredPromise();
promise
Getter
var result = deferredPromise.promise;
!Promise.<T>
reject
Getter
var result = deferredPromise.reject;
function(*)
Setter
deferredPromise.reject = value;
value
function(*)
resolve
Getter
var result = deferredPromise.resolve;
function(T|!Thenable.<T>)
Setter
deferredPromise.resolve = value;
value
function(T|!Thenable.<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
!libjass.ASS
The ASS object to which this dialogue belongs
alignment
Getter
The alignment number of this dialogue.
var result = dialogue.alignment;
number
containsTransformTag
Getter
Convenience getter for whether this dialogue contains a {\t} tag.
var result = dialogue.containsTransformTag;
boolean
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();
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

Enums

enum AttachmentType
The type of an attachment.
Font = 0
Graphic = 1
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

Namespace 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.

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 BrowserReadableStream implements Stream
A libjass.parser.Stream that reads from a ReadableStream object.
var browserReadableStream = new libjass.parser.BrowserReadableStream(stream, encoding);
stream
!ReadableStream
encoding
string
nextLine
var result = browserReadableStream.nextLine();
Returns
!Promise.<?string>
A promise that will be resolved with the next line, or null if the stream is exhausted.
_tryResolveNextLine
browserReadableStream._tryResolveNextLine();
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>
currentSection
Getter
var result = streamParser.currentSection;
number
Setter
streamParser.currentSection = value;
value
number
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 implements Stream
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 implements Stream
A libjass.parser.Stream that reads from an XMLHttpRequest object.
var xhrStream = new libjass.parser.XhrStream(xhr);
xhr
!XMLHttpRequest
The XMLHttpRequest object. Make sure to not call .open() on this object before passing it in here, since event handlers cannot be registered after open() has been called.
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.
_onXhrError
xhrStream._onXhrError(event);
event
!ErrorEvent
_onXhrLoad
xhrStream._onXhrLoad();
_onXhrProgress
xhrStream._onXhrProgress();
_tryResolveNextLine
xhrStream._tryResolveNextLine();

Namespace 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
?boolean|?number
{\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
interpolate
Returns a new Color by interpolating the current color to the final color by the given progression.
var result = color.interpolate(final, progression);
final
!libjass.parts.Color
progression
number
Returns
!libjass.parts.Color
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-###} -> relative difference (number, percentage)
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+###} -> relative difference (number, percentage)
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

Namespace libjass.parts.drawing

Interfaces

interface Instruction
The base interface of the drawing instructions.

Classes

class CubicBezierCurveInstruction implements Instruction
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 implements Instruction
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 implements Instruction
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

Namespace libjass.renderers

Interfaces

interface Clock
The clock interface. A clock is used by a renderer as a source of libjass.renderers.ClockEvents.
currentTime
Getter
var result = clock.currentTime;
number
Setter
clock.currentTime = value;
value
number
enabled
Getter
var result = clock.enabled;
boolean
Setter
clock.enabled = value;
value
boolean
paused
Getter
var result = clock.paused;
boolean
Setter
clock.paused = value;
value
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = clock.rate;
number
Setter
Gets the rate of the clock - how fast the clock ticks compared to real time.
clock.rate = value;
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 AutoClock implements Clock

An implementation of libjass.renderers.Clock that automatically ticks and generates libjass.renderers.ClockEvents according to the state of an external driver.

For example, if you're using libjass to render subtitles on a canvas with your own video controls, these video controls will function as the driver to this AutoClock. It would call libjass.renderers.AutoClock.play, libjass.renderers.AutoClock.pause, etc. when the user pressed the corresponding video controls.

The difference from ManualClock is that AutoClock does not require the driver to call something like libjass.renderers.ManualClock.tick. Instead it keeps its own time with a high-resolution requestAnimationFrame-based timer.

If using libjass with a <video> element, consider using libjass.renderers.VideoClock that uses the video element as a driver.

var autoClock = new libjass.renderers.AutoClock(getCurrentTime, autoPauseAfter);
getCurrentTime
function():number
A callback that will be invoked to get the current time of the external driver.
autoPauseAfter
number
If two calls to getCurrentTime are more than autoPauseAfter milliseconds apart but return the same time, then the external driver will be considered to have paused.
currentTime
Getter
var result = autoClock.currentTime;
number
enabled
Getter
var result = autoClock.enabled;
boolean
paused
Getter
var result = autoClock.paused;
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = autoClock.rate;
number
addEventListener
autoClock.addEventListener(type, listener);
type
number
listener
!Function
disable
Disable the clock.
var result = autoClock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable
Enable the clock.
var result = autoClock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
pause
Tells the clock to pause.
autoClock.pause();
play
Tells the clock to start generating ticks.
autoClock.play();
seeking
Tells the clock that the external driver is seeking.
autoClock.seeking();
setEnabled
Enable or disable the clock.
var result = autoClock.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.
autoClock.setRate(rate);
rate
number
The new rate of the clock.
toggle
Toggle the clock.
autoClock.toggle();
_onTimerTick
autoClock._onTimerTick(timeStamp);
timeStamp
number
_startTicking
autoClock._startTicking();
_stopTicking
autoClock._stopTicking();
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
resize

Resize the subtitles to the dimensions of the video element.

This method accounts for letterboxing if the video element's size is not the same ratio as the video resolution.

defaultRenderer.resize();
resizeVideo
@deprecated
defaultRenderer.resizeVideo();
_ready
defaultRenderer._ready();
class EventSource.<T>
A mixin class that represents an event source.
var eventSource = new libjass.renderers.EventSource();
_eventListeners
Getter
A map from event type to an array of all the listeners registered for that event type.
var result = eventSource._eventListeners;
!Map.<T, !Array.<Function>>
Setter
A map from event type to an array of all the listeners registered for that event type.
eventSource._eventListeners = value;
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 implements Clock, EventSource.<ClockEvent>
An implementation of libjass.renderers.Clock that allows user script to manually trigger libjass.renderers.ClockEvents.
var manualClock = new libjass.renderers.ManualClock();
_dispatchEvent
Getter
var result = manualClock._dispatchEvent;
function(number, Array.<*>)
Setter
manualClock._dispatchEvent = value;
value
function(number, Array.<*>)
_eventListeners
Getter
var result = manualClock._eventListeners;
!Map.<T, !Array.<Function>>
Setter
manualClock._eventListeners = value;
value
!Map.<T, !Array.<Function>>
addEventListener
Getter
var result = manualClock.addEventListener;
function(number, !Function)
Setter
manualClock.addEventListener = value;
value
function(number, !Function)
currentTime
Getter
var result = manualClock.currentTime;
number
enabled
Getter
var result = manualClock.enabled;
boolean
paused
Getter
var result = manualClock.paused;
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();
seek
Seek to the given time. Unlike libjass.renderers.ManualClock.tick this is used to represent a discontinuous jump, such as the user seeking via the video element's position bar.
manualClock.seek(time);
time
number
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 with the given time.
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();
enableSvg
Getter

Outlines and blur are implemented using SVG filters by default. When false, they will be rendered using alternative means.

IE 11 and below do not support SVG filters on HTML elements so this should be set to false there. See http://caniuse.com/svg-html for details.

Defaults to true.

var result = rendererSettings.enableSvg;
boolean
Setter

Outlines and blur are implemented using SVG filters by default. When false, they will be rendered using alternative means.

IE 11 and below do not support SVG filters on HTML elements so this should be set to false there. See http://caniuse.com/svg-html for details.

Defaults to true.

rendererSettings.enableSvg = value;
value
boolean
fallbackFonts
Getter

Comma-separated list of fonts to be used when font specified in ASS Styles not loaded.

The value should be a valid CSS font-family property (i.e. comma-separated and individual names in quotes if necessary). Use empty string to disable fallback.

Defaults to 'Arial, Helvetica, sans-serif, "Segoe UI Symbol"'.

var result = rendererSettings.fallbackFonts;
string
Setter

Comma-separated list of fonts to be used when font specified in ASS Styles not loaded.

The value should be a valid CSS font-family property (i.e. comma-separated and individual names in quotes if necessary). Use empty string to disable fallback.

Defaults to 'Arial, Helvetica, sans-serif, "Segoe UI Symbol"'.

rendererSettings.fallbackFonts = value;
value
string
fontMap
Getter

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.

The key of each entry of the map is the font name used in the ASS script. There are three choices for the value:

- A single string that you would use for the src attribute of a @font-face rule. Eg: `'url("/fonts.foo.ttf"), url("/fonts/foo-fallback.ttf"), local("Arial.ttf")'`

- An array of the individual sources that you would use for the src attribute of a @font-face rule. Eg: `['url("/fonts.foo.ttf")', 'url("/fonts/foo-fallback.ttf")', 'local("Arial")']`

- An array of URLs. Eg: `["/fonts.foo.ttf", "/fonts/foo-fallback.ttf"]`

Only the first and second forms allow you to use local fonts. The third form only allows you to use remote fonts.

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.

Defaults to null.

var result = rendererSettings.fontMap;
Map.<string, (string|!Array.<string>)>
Setter

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.

The key of each entry of the map is the font name used in the ASS script. There are three choices for the value:

- A single string that you would use for the src attribute of a @font-face rule. Eg: `'url("/fonts.foo.ttf"), url("/fonts/foo-fallback.ttf"), local("Arial.ttf")'`

- An array of the individual sources that you would use for the src attribute of a @font-face rule. Eg: `['url("/fonts.foo.ttf")', 'url("/fonts/foo-fallback.ttf")', 'local("Arial")']`

- An array of URLs. Eg: `["/fonts.foo.ttf", "/fonts/foo-fallback.ttf"]`

Only the first and second forms allow you to use local fonts. The third form only allows you to use remote fonts.

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.

Defaults to null.

rendererSettings.fontMap = value;
value
Map.<string, (string|!Array.<string>)>
preciseOutlines
Getter

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;
boolean
Setter

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.

rendererSettings.preciseOutlines = value;
value
boolean
preRenderTime
Getter

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

Defaults to 5.

var result = rendererSettings.preRenderTime;
number
Setter

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

Defaults to 5.

rendererSettings.preRenderTime = value;
value
number
useAttachedFonts
Getter

If true, attached TTF fonts in the ASS script will be used. The font is loaded as a data: URI. Requires ES6 typed arrays (ArrayBuffer, DataView, Uint8Array, etc).

The font is naively parsed to extract the strings that will be used as the font family. Do not use this option with untrusted fonts or scripts.

Defaults to false.

var result = rendererSettings.useAttachedFonts;
boolean
Setter

If true, attached TTF fonts in the ASS script will be used. The font is loaded as a data: URI. Requires ES6 typed arrays (ArrayBuffer, DataView, Uint8Array, etc).

The font is naively parsed to extract the strings that will be used as the font family. Do not use this option with untrusted fonts or scripts.

Defaults to false.

rendererSettings.useAttachedFonts = value;
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. There should be one @font-face rule for each font name, mapping to a font file URL.

For example:

@font-face {
    font-family: "Helvetica";
    src: url("/fonts/helvetica.ttf"), local("Arial");
}

More complicated @font-face syntax like format() or multi-line src are not supported.

var result = libjass.renderers.RendererSettings.makeFontMapFromStyleElement(linkStyle);
linkStyle
!LinkStyle
Returns
!Map.<string, string>
class VideoClock implements Clock
An implementation of libjass.renderers.Clock that generates libjass.renderers.ClockEvents according to the state of a <video> element.
var videoClock = new libjass.renderers.VideoClock(video);
video
!HTMLVideoElement
currentTime
Getter
var result = videoClock.currentTime;
number
enabled
Getter
var result = videoClock.enabled;
boolean
paused
Getter
var result = videoClock.paused;
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = videoClock.rate;
number
addEventListener
videoClock.addEventListener(type, listener);
type
number
listener
!Function
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();
class WebRenderer extends NullRenderer implements EventSource.<string>

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

After the renderer fires its ready event, libjass.renderers.WebRenderer.resize must be called to initialize its size before starting the clock.

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
Getter
var result = webRenderer._dispatchEvent;
function(number, Array.<*>)
Setter
webRenderer._dispatchEvent = value;
value
function(number, Array.<*>)
_eventListeners
Getter
var result = webRenderer._eventListeners;
!Map.<T, !Array.<Function>>
Setter
webRenderer._eventListeners = value;
value
!Map.<T, !Array.<Function>>
addEventListener
Getter
var result = webRenderer.addEventListener;
function(number, !Function)
Setter
webRenderer.addEventListener = value;
value
function(number, !Function)
libjassSubsWrapper
Getter
var result = webRenderer.libjassSubsWrapper;
!HTMLDivElement
draw
Returns the subtitle div for display. The libjass.renderers.Clock.currentTime of the libjass.renderers.NullRenderer.clock 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.
var result = webRenderer.preRender(dialogue);
dialogue
!libjass.Dialogue
Returns
PreRenderedSub
resize
Resize the subtitles to the given new dimensions.
webRenderer.resize(width, height, left, top);
width
number
height
number
left
number=0
top
number=0
_onClockPause
webRenderer._onClockPause();
_onClockPlay
webRenderer._onClockPlay();
_onClockRateChange
webRenderer._onClockRateChange();
_onClockStop
webRenderer._onClockStop();
_onClockTick
webRenderer._onClockTick();
_ready
webRenderer._ready();
_calculateFontMetricsAfterFetch
var result = webRenderer._calculateFontMetricsAfterFetch(fontFamily, fontFetchPromise);
fontFamily
string
fontFetchPromise
!Promise.<*>
Returns
!Promise.<[number, number]>
_removeAllSubs
webRenderer._removeAllSubs();
_removeSub
webRenderer._removeSub(sub);
sub
!HTMLDivElement

Enums

enum ClockEvent
The type of clock event.
Play = 0
Tick = 1
Pause = 2
Stop = 3
RateChange = 4

Namespace libjass.webworker

Properties

supported
Getter
Indicates whether web workers are supposed in this environment or not.
var result = libjass.webworker.supported;
boolean

Free functions

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

Enums

enum WorkerCommands
The commands that can be sent to or from a web worker.
Response = 0
Parse = 1
Ping = 2

Module ./parser/misc

Free functions

parseLineIntoProperty
Parses a line into a ./types/misc.Property.
var result = parseLineIntoProperty(line);
line
string
Returns
Property
parseLineIntoTypedTemplate
Parses a line into a ./types/misc.TypedTemplate according to the given format specifier.
var result = parseLineIntoTypedTemplate(line, formatSpecifier);
line
string
formatSpecifier
!Array.<string>
Returns
TypedTemplate

Module ./parser/parse

Free functions

makeTagParserFunction
Constructs a simple tag parser function and sets it on the prototype of the ./parser/parse.ParserRun class.
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

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 ParseNode(parent, value);
parent
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;
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 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;
ParseNode
parse_alpha
var result = parserRun.parse_alpha(parent);
parent
!ParseNode
Returns
ParseNode
parse_color
var result = parserRun.parse_color(parent);
parent
!ParseNode
Returns
ParseNode
parse_colorWithAlpha
var result = parserRun.parse_colorWithAlpha(parent);
parent
!ParseNode
Returns
ParseNode
parse_comment
var result = parserRun.parse_comment(parent);
parent
!ParseNode
Returns
ParseNode
parse_decimal
var result = parserRun.parse_decimal(parent);
parent
!ParseNode
Returns
ParseNode
parse_decimalInt32
var result = parserRun.parse_decimalInt32(parent);
parent
!ParseNode
Returns
ParseNode
parse_decimalOrHexInt32
var result = parserRun.parse_decimalOrHexInt32(parent);
parent
!ParseNode
Returns
ParseNode
parse_dialogueParts
var result = parserRun.parse_dialogueParts(parent);
parent
!ParseNode
Returns
ParseNode
parse_drawingInstructions
var result = parserRun.parse_drawingInstructions(parent);
parent
!ParseNode
Returns
ParseNode
parse_enableDisable
var result = parserRun.parse_enableDisable(parent);
parent
!ParseNode
Returns
ParseNode
parse_enclosedTags
var result = parserRun.parse_enclosedTags(parent);
parent
!ParseNode
Returns
ParseNode
parse_hardspace
var result = parserRun.parse_hardspace(parent);
parent
!ParseNode
Returns
ParseNode
parse_hexInt32
var result = parserRun.parse_hexInt32(parent);
parent
!ParseNode
Returns
ParseNode
parse_newline
var result = parserRun.parse_newline(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_1a
var result = parserRun.parse_tag_1a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_1c
var result = parserRun.parse_tag_1c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_2a
var result = parserRun.parse_tag_2a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_2c
var result = parserRun.parse_tag_2c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_3a
var result = parserRun.parse_tag_3a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_3c
var result = parserRun.parse_tag_3c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_4a
var result = parserRun.parse_tag_4a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_4c
var result = parserRun.parse_tag_4c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_a
var result = parserRun.parse_tag_a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_alpha
var result = parserRun.parse_tag_alpha(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_an
var result = parserRun.parse_tag_an(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_b
var result = parserRun.parse_tag_b(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_be
var result = parserRun.parse_tag_be(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_blur
var result = parserRun.parse_tag_blur(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_bord
var result = parserRun.parse_tag_bord(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_c
var result = parserRun.parse_tag_c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_clip
var result = parserRun.parse_tag_clip(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fad
var result = parserRun.parse_tag_fad(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fade
var result = parserRun.parse_tag_fade(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fax
var result = parserRun.parse_tag_fax(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fay
var result = parserRun.parse_tag_fay(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fn
var result = parserRun.parse_tag_fn(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fr
var result = parserRun.parse_tag_fr(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_frx
var result = parserRun.parse_tag_frx(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fry
var result = parserRun.parse_tag_fry(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_frz
var result = parserRun.parse_tag_frz(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fs
var result = parserRun.parse_tag_fs(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fscx
var result = parserRun.parse_tag_fscx(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fscy
var result = parserRun.parse_tag_fscy(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fsminus
var result = parserRun.parse_tag_fsminus(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fsp
var result = parserRun.parse_tag_fsp(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fsplus
var result = parserRun.parse_tag_fsplus(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_i
var result = parserRun.parse_tag_i(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_iclip
var result = parserRun.parse_tag_iclip(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_k
var result = parserRun.parse_tag_k(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_K
var result = parserRun.parse_tag_K(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_kf
var result = parserRun.parse_tag_kf(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_ko
var result = parserRun.parse_tag_ko(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_move
var result = parserRun.parse_tag_move(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_org
var result = parserRun.parse_tag_org(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_p
var result = parserRun.parse_tag_p(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_pbo
var result = parserRun.parse_tag_pbo(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_pos
var result = parserRun.parse_tag_pos(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_q
var result = parserRun.parse_tag_q(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_r
var result = parserRun.parse_tag_r(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_s
var result = parserRun.parse_tag_s(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_shad
var result = parserRun.parse_tag_shad(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_t
var result = parserRun.parse_tag_t(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_u
var result = parserRun.parse_tag_u(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_xbord
var result = parserRun.parse_tag_xbord(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_xshad
var result = parserRun.parse_tag_xshad(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_ybord
var result = parserRun.parse_tag_ybord(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_yshad
var result = parserRun.parse_tag_yshad(parent);
parent
!ParseNode
Returns
ParseNode
parse_text
var result = parserRun.parse_text(parent);
parent
!ParseNode
Returns
ParseNode
parse_unsignedDecimal
var result = parserRun.parse_unsignedDecimal(parent);
parent
!ParseNode
Returns
ParseNode
read
var result = parserRun.read(parent, next);
parent
!ParseNode
next
string
Returns
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
!ParseNode
Returns
ParseNode
_peek
var result = parserRun._peek(count);
count
number=1
Returns
string

Module ./parser/stream-parsers

Free functions

uuencodedToBase64
Converts a uuencoded string to a base64 string.
var result = uuencodedToBase64(str);
str
string
Returns
string

Enums

enum Section
ScriptInfo = 0
Styles = 1
Events = 2
Fonts = 3
Graphics = 4
Other = 5
EOF = 6

Module ./parser/streams

Interfaces

interface ReadableStream
getReader
var result = readableStream.getReader();
Returns
!ReadableStreamReader
interface ReadableStreamReader
read
var result = readableStreamReader.read();
Returns
!Promise.<{ value?: Uint8Array, done: boolean }>
interface TextDecoder
decode
var result = textDecoder.decode(input, options);
input
!ArrayBuffer|!ArrayBufferView
options
{ stream: boolean }
Returns
string
interface TextDecoderConstructor
prototype
Getter
var result = textDecoderConstructor.prototype;
!TextDecoder
Setter
textDecoderConstructor.prototype = value;
value
!TextDecoder

Module ./parser/ttf

Free functions

getTtfNames
Gets all the font names from the given font attachment.
var result = getTtfNames(attachment);
attachment
!libjass.Attachment
Returns
!libjass.Set.<string>
field.<T>
var result = field(type);
type
number
Returns
function(T, string)
struct.<T>
var result = struct(clazz);
clazz
!function(new(): T)
Returns
!function(new(): T)

Classes

class NameRecord
var nameRecord = new NameRecord();
encodingId
Getter
var result = nameRecord.encodingId;
number
Setter
nameRecord.encodingId = value;
value
number
languageId
Getter
var result = nameRecord.languageId;
number
Setter
nameRecord.languageId = value;
value
number
length
Getter
var result = nameRecord.length;
number
Setter
nameRecord.length = value;
value
number
nameId
Getter
var result = nameRecord.nameId;
number
Setter
nameRecord.nameId = value;
value
number
offset
Getter
var result = nameRecord.offset;
number
Setter
nameRecord.offset = value;
value
number
platformId
Getter
var result = nameRecord.platformId;
number
Setter
nameRecord.platformId = value;
value
number
read
Getter
var result = nameRecord.read;
function(!{ dataView: DataView, position: number }): NameRecord
Setter
nameRecord.read = value;
value
function(!{ dataView: DataView, position: number }): NameRecord
class NameTableHeader
var nameTableHeader = new NameTableHeader();
count
Getter
var result = nameTableHeader.count;
number
Setter
nameTableHeader.count = value;
value
number
formatSelector
Getter
var result = nameTableHeader.formatSelector;
number
Setter
nameTableHeader.formatSelector = value;
value
number
read
Getter
var result = nameTableHeader.read;
function(!{ dataView: DataView, position: number }): NameTableHeader
Setter
nameTableHeader.read = value;
value
function(!{ dataView: DataView, position: number }): NameTableHeader
stringOffset
Getter
var result = nameTableHeader.stringOffset;
number
Setter
nameTableHeader.stringOffset = value;
value
number
class OffsetTable
var offsetTable = new OffsetTable();
entrySelector
Getter
var result = offsetTable.entrySelector;
number
Setter
offsetTable.entrySelector = value;
value
number
majorVersion
Getter
var result = offsetTable.majorVersion;
number
Setter
offsetTable.majorVersion = value;
value
number
minorVersion
Getter
var result = offsetTable.minorVersion;
number
Setter
offsetTable.minorVersion = value;
value
number
numTables
Getter
var result = offsetTable.numTables;
number
Setter
offsetTable.numTables = value;
value
number
rangeShift
Getter
var result = offsetTable.rangeShift;
number
Setter
offsetTable.rangeShift = value;
value
number
read
Getter
var result = offsetTable.read;
function(!{ dataView: DataView, position: number }): OffsetTable
Setter
offsetTable.read = value;
value
function(!{ dataView: DataView, position: number }): OffsetTable
searchRange
Getter
var result = offsetTable.searchRange;
number
Setter
offsetTable.searchRange = value;
value
number
class TableRecord
var tableRecord = new TableRecord();
c1
Getter
var result = tableRecord.c1;
string
Setter
tableRecord.c1 = value;
value
string
c2
Getter
var result = tableRecord.c2;
string
Setter
tableRecord.c2 = value;
value
string
c3
Getter
var result = tableRecord.c3;
string
Setter
tableRecord.c3 = value;
value
string
c4
Getter
var result = tableRecord.c4;
string
Setter
tableRecord.c4 = value;
value
string
checksum
Getter
var result = tableRecord.checksum;
number
Setter
tableRecord.checksum = value;
value
number
length
Getter
var result = tableRecord.length;
number
Setter
tableRecord.length = value;
value
number
offset
Getter
var result = tableRecord.offset;
number
Setter
tableRecord.offset = value;
value
number
read
Getter
var result = tableRecord.read;
function(!{ dataView: DataView, position: number }): TableRecord
Setter
tableRecord.read = value;
value
function(!{ dataView: DataView, position: number }): TableRecord

Enums

enum DataType
Char = 0
Uint16 = 1
Uint32 = 2

Module ./renderers/settings

Free functions

isFontFaceRule
var result = isFontFaceRule(rule);
rule
!CSSRule
Returns
boolean
testSupportsSvg
Returns true if this environment may support SVG filter effects. May return false positives.
var result = testSupportsSvg();
Returns
boolean

Module ./renderers/web/animation-collection

Classes

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, style);
renderer
!libjass.renderers.NullRenderer
The renderer that this collection is associated with
style
!HTMLStyleElement
A <style> element to insert the animation rules into
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
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.<!libjass.renderers.Keyframe>

Module ./renderers/web/drawing-styles

Classes

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

Module ./renderers/web/font-size

Free functions

calculateFontMetrics
Calculates font metrics for the given font family.
var result = calculateFontMetrics(fontFamily, fallbackFonts, fontSizeElement);
fontFamily
string
fallbackFonts
string
fontSizeElement
!HTMLDivElement
Returns
!Promise.<number>
fontSizeForLineHeight

Uses linear interpolation to calculate the CSS font size that would give the specified line height for the specified font family.

WARNING: If fontMetricsCache doesn't already contain a cached value for this font family, and it is not a font already installed on the user's device, then this function may return wrong values. To avoid this, make sure to preload the font using the libjass.renderers.RendererSettings.fontMap property when constructing the renderer.

var result = fontSizeForLineHeight(fontFamily, lineHeight, fallbackFonts, fontSizeElement, fontMetricsCache);
fontFamily
string
lineHeight
number
fallbackFonts
string
fontSizeElement
!HTMLDivElement
fontMetricsCache
!Map.<string, [number, number]>
Returns
number
fontMetricsFromLineHeights
var result = fontMetricsFromLineHeights(lowerLineHeight, upperLineHeight);
lowerLineHeight
number
upperLineHeight
number
Returns
[number, number]
fontSizeFromMetrics
var result = fontSizeFromMetrics(lineHeight, lowerLineHeight, factor);
lineHeight
number
lowerLineHeight
number
factor
number
Returns
number
lineHeightForFontSize
var result = lineHeightForFontSize(fontFamily, fontSize, fallbackFonts, fontSizeElement);
fontFamily
string
fontSize
number
fallbackFonts
string
fontSizeElement
!HTMLDivElement
Returns
!Promise.<number>
lineHeightForFontSizeSync
var result = lineHeightForFontSizeSync(fontFamily, fontSize, fallbackFonts, fontSizeElement);
fontFamily
string
fontSize
number
fallbackFonts
string
fontSizeElement
!HTMLDivElement
Returns
number
prepareFontSizeElement
prepareFontSizeElement(fontFamily, fontSize, fallbackFonts, fontSizeElement);
fontFamily
string
fontSize
number
fallbackFonts
string
fontSizeElement
!HTMLDivElement

Module ./renderers/web/keyframe

Classes

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
!Map.<string, string>
properties
Getter
var result = keyframe.properties;
!Map.<string, string>
time
Getter
var result = keyframe.time;
number

Module ./renderers/web/renderer

Interfaces

interface PreRenderedSub
animationDelays
Getter
var result = preRenderedSub.animationDelays;
!Map.<string, number>
Setter
preRenderedSub.animationDelays = value;
value
!Map.<string, number>
sub
Getter
var result = preRenderedSub.sub;
!HTMLDivElement
Setter
preRenderedSub.sub = value;
value
!HTMLDivElement
interface FontFace
family
Getter
var result = fontFace.family;
string
Setter
fontFace.family = value;
value
string
load
var result = fontFace.load();
Returns
!Promise.<!FontFace>
interface FontFaceSet
add
var result = fontFaceSet.add(fontFace);
fontFace
!FontFace
Returns
!FontFaceSet
forEach
fontFaceSet.forEach(callbackfn, thisArg);
callbackfn
function(!FontFace, !FontFace, !FontFaceSet)
A function that is called with each value in the set.
thisArg
*

Module ./renderers/web/span-styles

Free functions

createComponentTransferFilter
var result = createComponentTransferFilter(color);
color
!libjass.parts.Color
Returns
!SVGFEComponentTransferElement
valueOrDefault.<T>
var result = valueOrDefault(newValue, defaultValue);
newValue
?T
defaultValue
!T
Returns
!T

Classes

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, fontMetricsCache);
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
fontMetricsCache
!Map<string, [number, number]>
Font metrics cache
blur
Getter
Gets the blur property.
var result = spanStyles.blur;
number
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
(?boolean|?number)
fontName
Setter
Sets the font name property. null defaults it to the default style's value.
spanStyles.fontName = value;
value
?string
fontScaleX
Getter
Gets the horizontal font scaling property.
var result = spanStyles.fontScaleX;
number
Setter
Sets the horizontal font scaling property. null defaults it to the default style's value.
spanStyles.fontScaleX = value;
value
?number
fontScaleY
Getter
Gets the vertical font scaling property.
var result = spanStyles.fontScaleY;
number
Setter
Sets the vertical font scaling property. null defaults it to the default style's value.
spanStyles.fontScaleY = value;
value
?number
fontSize
Getter
Gets the font size property.
var result = spanStyles.fontSize;
number
Setter
Sets the font size property. null defaults it to the default style's value.
spanStyles.fontSize = value;
value
?number
gaussianBlur
Getter
Gets the Gaussian blur property.
var result = spanStyles.gaussianBlur;
number
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
Getter
Gets the letter spacing property.
var result = spanStyles.letterSpacing;
number
Setter
Sets the letter spacing property. null defaults it to the default style's value.
spanStyles.letterSpacing = value;
value
?number
outlineAlpha
Getter
Gets the outline alpha property.
var result = spanStyles.outlineAlpha;
number
Setter
Sets the outline alpha property.
spanStyles.outlineAlpha = value;
value
?number
outlineColor
Getter
Gets the outline color property.
var result = spanStyles.outlineColor;
!libjass.Color
Setter
Sets the outline color property. null defaults it to the default style's value.
spanStyles.outlineColor = value;
value
libjass.Color
outlineHeight
Getter
Gets the outline height property.
var result = spanStyles.outlineHeight;
number
Setter
Sets the outline height property. null defaults it to the style's original outline height value.
spanStyles.outlineHeight = value;
value
?number
outlineWidth
Getter
Gets the outline width property.
var result = spanStyles.outlineWidth;
number
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.Color
Setter
Sets the primary color property. null defaults it to the default style's value.
spanStyles.primaryColor = value;
value
libjass.Color
rotationX
Getter
Gets the X-axis rotation property.
var result = spanStyles.rotationX;
number
Setter
Sets the X-axis rotation property.
spanStyles.rotationX = value;
value
?number
rotationY
Getter
Gets the Y-axis rotation property.
var result = spanStyles.rotationY;
number
Setter
Sets the Y-axis rotation property.
spanStyles.rotationY = value;
value
?number
rotationZ
Getter
Gets the Z-axis rotation property.
var result = spanStyles.rotationZ;
number
Setter
Sets the Z-axis rotation property.
spanStyles.rotationZ = value;
value
?number
secondaryAlpha
Getter
Gets the secondary alpha property.
var result = spanStyles.secondaryAlpha;
number
Setter
Sets the secondary alpha property.
spanStyles.secondaryAlpha = value;
value
?number
secondaryColor
Getter
Gets the secondary color property.
var result = spanStyles.secondaryColor;
!libjass.Color
Setter
Sets the secondary color property. null defaults it to the default style's value.
spanStyles.secondaryColor = value;
value
libjass.Color
shadowAlpha
Getter
Gets the shadow alpha property.
var result = spanStyles.shadowAlpha;
number
Setter
Sets the shadow alpha property.
spanStyles.shadowAlpha = value;
value
?number
shadowColor
Getter
Gets the shadow color property.
var result = spanStyles.shadowColor;
!libjass.Color
Setter
Sets the shadow color property. null defaults it to the default style's value.
spanStyles.shadowColor = value;
value
libjass.Color
shadowDepthX
Getter
Gets the shadow width property.
var result = spanStyles.shadowDepthX;
number
Setter
Sets the shadow width property. null defaults it to the style's original shadow depth value.
spanStyles.shadowDepthX = value;
value
?number
shadowDepthY
Getter
Gets the shadow height property.
var result = spanStyles.shadowDepthY;
number
Setter
Sets the shadow height property. null defaults it to the style's original shadow depth value.
spanStyles.shadowDepthY = value;
value
?number
skewX
Getter
Gets the X-axis skew property.
var result = spanStyles.skewX;
number
Setter
Sets the X-axis skew property.
spanStyles.skewX = value;
value
?number
skewY
Getter
Gets the Y-axis skew property.
var result = spanStyles.skewY;
number
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
makeNewLine
var result = spanStyles.makeNewLine();
Returns
!HTMLBRElement
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, animationCollection);
span
!HTMLSpanElement
animationCollection
!AnimationCollection
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.
_svg
spanStyles._svg(span, outlineWidth, outlineHeight, outlineColor, shadowDepthX, shadowDepthY, shadowColor);
span
!HTMLSpanElement
outlineWidth
number
outlineHeight
number
outlineColor
!libjass.parts.Color
shadowDepthX
number
shadowDepthY
number
shadowColor
!libjass.parts.Color
_textShadow
spanStyles._textShadow(span, outlineWidth, outlineHeight, outlineColor, shadowDepthX, shadowDepthY, shadowColor);
span
!HTMLSpanElement
outlineWidth
number
outlineHeight
number
outlineColor
!libjass.parts.Color
shadowDepthX
number
shadowDepthY
number
shadowColor
!libjass.parts.Color

Module ./serialization

Free functions

registerClass
Registers a class as a serializable type.
registerClass(clazz);
clazz
function(new:*)

Module ./settings

Free functions

setDebugMode
Sets the debug mode.
setDebugMode(value);
value
boolean
setVerboseMode
Sets the verbose debug mode.
setVerboseMode(value);
value
boolean

Module ./types/dialogue

Free functions

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 = toTime(str);
str
string
Returns
number

Module ./types/misc

Free functions

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
Getter
var result = property.name;
string
Setter
property.name = value;
value
string
value
Getter
var result = property.value;
string
Setter
property.value = value;
value
string
interface TypedTemplate
A template object with a particular type.
template
Getter
var result = typedTemplate.template;
!Map.<string, string>
Setter
typedTemplate.template = value;
value
!Map.<string, string>
type
Getter
var result = typedTemplate.type;
string
Setter
typedTemplate.type = value;
value
string

Module ./utility/map

Free functions

setImplementation
Sets the Map implementation used by libjass to the provided one. If null, ./utility/map.SimpleMap is used.
setImplementation(value);
value
?function(new:Map, !Array.<!Array.<*>>=)

Classes

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(iterable);
iterable
!Array.<!Array.<*>>=
Only an array of elements (where each element is a 2-tuple of key and value) is supported.
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

Module ./utility/mixin

Free functions

mixin
Adds properties of the given mixins' prototypes to the given class's prototype.
mixin(clazz, mixins);
clazz
!*
mixins
!Array.<*>

Module ./utility/promise

Free functions

any.<T>
Returns a promise that resolves to the first (in time order) promise that fulfills, and rejects if all the promises reject.
var result = any(promises);
promises
!Array.<!Promise.<T>>
Returns
!Promise.<T>
first.<T>
Returns a promise that resolves to the first (in iteration order) promise that fulfills, and rejects if all the promises reject.
var result = first(promises);
promises
!Array.<!Promise.<T>>
Returns
!Promise.<T>
lastly.<T>
Returns a promise that runs the given callback when the promise has resolved regardless of whether it fulfilled or rejected.
var result = lastly(promise, body);
promise
!Promise.<T>
body
function()
Returns
!Promise.<T>
setImplementation
Sets the Promise implementation used by libjass to the provided one. If null, ./utility/promise.SimplePromise is used.
setImplementation(value);
value
?function(new:Promise)
first_rec.<T>
var result = first_rec(promises, previousRejections);
promises
!Array.<!Promise.<T>>
previousRejections
!Array.<*>
Returns
!Promise.<T>

Interfaces

interface Thenable.<T>
then
Getter
var result = thenable.then;
function(this:!Thenable.<T>, function(T|!Thenable.<T>), function(*))
Setter
thenable.then = value;
value
function(this:!Thenable.<T>, function(T|!Thenable.<T>), function(*))
interface ThenableThen.<T>
interface FulfilledPromiseReaction.<T, U>
capabilities
Getter
var result = fulfilledPromiseReaction.capabilities;
!libjass.DeferredPromise.<U>
Setter
fulfilledPromiseReaction.capabilities = value;
value
!libjass.DeferredPromise.<U>
handler
var result = fulfilledPromiseReaction.handler(value);
value
T
Returns
U|!Thenable.<U>
interface RejectedPromiseReaction.<U>
capabilities
Getter
var result = rejectedPromiseReaction.capabilities;
!libjass.DeferredPromise.<U>
Setter
rejectedPromiseReaction.capabilities = value;
value
!libjass.DeferredPromise.<U>
handler
var result = rejectedPromiseReaction.handler(reason);
reason
*
Returns
U|!Thenable.<U>

Classes

class SimplePromise.<T>
Promise implementation for browsers that don't support it.
var simplePromise = new SimplePromise(executor);
executor
function(function(T|!Thenable.<T>), function(*))
all.<T>
var result = SimplePromise.all(values);
values
!Array.<T|!Thenable.<T>>
Returns
!Promise.<!Array.<T>>
catch
var result = simplePromise.catch(onRejected);
onRejected
function(*):(T|!Thenable.<T>)
Returns
!Promise.<T>
race.<T>
var result = SimplePromise.race(values);
values
!Array.<T|!Thenable.<T>>
Returns
!Promise.<T>
reject.<T>
var result = SimplePromise.reject(reason);
reason
*
Returns
!Promise.<T>
resolve.<T>
var result = SimplePromise.resolve(value);
value
T|!Thenable.<T>
Returns
!Promise.<T>
then.<U>
var result = simplePromise.then(onFulfilled, onRejected);
onFulfilled
?function(T):(U|!Thenable.<U>)
onRejected
?function(*):(U|!Thenable.<U>)
Returns
!Promise.<U>
_createResolvingFunctions
var result = simplePromise._createResolvingFunctions();
Returns
{ resolve(T|!Thenable.<T>), reject(*) }
_enqueueFulfilledReactionJob
simplePromise._enqueueFulfilledReactionJob(reaction, value);
reaction
!FulfilledPromiseReaction.<T, *>
value
T
_enqueueRejectedReactionJob
simplePromise._enqueueRejectedReactionJob(reaction, reason);
reaction
!RejectedPromiseReaction.<*>
reason
*
_fulfill
simplePromise._fulfill(value);
value
T
_reject
simplePromise._reject(reason);
reason
*
_resolveWithThenable
simplePromise._resolveWithThenable(thenable, then);
thenable
!Thenable.<T>
then
{function(this:!Thenable.<T>, function(T|!Thenable.<T>), function(*))}

Enums

enum SimplePromiseState
The state of the ./utility/promise.SimplePromise
PENDING = 0
FULFILLED = 1
REJECTED = 2

Module ./utility/set

Free functions

setImplementation
Sets the Set implementation used by libjass to the provided one. If null, ./utility/set.SimpleSet is used.
setImplementation(value);
value
?function(new:Set, !Array.<T>=)

Classes

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(iterable);
iterable
!Array.<T>=
Only an array of values is supported.
size
Getter
var result = simpleSet.size;
number
add
var result = simpleSet.add(value);
value
T
Returns
libjass.Set.<T>
This set
clear
simpleSet.clear();
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

Module ./webworker/channel

Interfaces

interface WorkerCommandHandler
The signature of a handler registered to handle a particular command in libjass.webworker.WorkerCommands
interface WorkerCommunication
The interface implemented by a communication channel to the other side.
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
Getter
The command type of this request.
var result = workerRequestMessage.command;
number
Setter
The command type of this request.
workerRequestMessage.command = value;
value
number
parameters
Getter
Any parameters serialized with this request.
var result = workerRequestMessage.parameters;
*
Setter
Any parameters serialized with this request.
workerRequestMessage.parameters = value;
value
*
requestId
Getter
An internal identifier for this request. Used to connect responses to their corresponding requests.
var result = workerRequestMessage.requestId;
number
Setter
An internal identifier for this request. Used to connect responses to their corresponding requests.
workerRequestMessage.requestId = value;
value
number
interface WorkerResponseMessage
The interface implemented by a response received from the other side of the communication channel.
error
Getter
Set if the computation of this response resulted in an error.
var result = workerResponseMessage.error;
*
Setter
Set if the computation of this response resulted in an error.
workerResponseMessage.error = value;
value
*
requestId
Getter
An internal identifier for this response. Used to connect responses to their corresponding requests.
var result = workerResponseMessage.requestId;
number
Setter
An internal identifier for this response. Used to connect responses to their corresponding requests.
workerResponseMessage.requestId = value;
value
number
result
Getter
The result of computing this response.
var result = workerResponseMessage.result;
*
Setter
The result of computing this response.
workerResponseMessage.result = value;
value
*

Classes

class WorkerChannelImpl implements WorkerChannel
Internal implementation of libjass.webworker.WorkerChannel
var workerChannelImpl = new WorkerChannelImpl(comm);
comm
!*
The object used to talk to the other side of the channel. When created by the main thread, this is the Worker object. 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.<*>
_onMessage
workerChannelImpl._onMessage(rawMessage);
rawMessage
string
_respond
workerChannelImpl._respond(message);
message
!WorkerResponseMessage

Module ./webworker/misc

Free functions

getWorkerCommandHandler
Gets the handler for the given worker command.
var result = getWorkerCommandHandler(command);
command
number
Returns
?function(*, function(*, *))
registerWorkerCommand
Registers a handler for the given worker command.
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