Skip to content

Module: src/text/SubtitleRendererIsd

SubtitleRendererIsd is a plugin renderer for subtitles in TTML format. It is registered with the Subtitles component and creates DOM output from isd (Intermediate Synchronic Document) subtitle cues. The renderer currently supports very basic structure parsing (div, p, span, br) and ignores formatting and styling instructions. This component is intended for rendering embedded TTML subtitles provided by streaming engines like DASH.js.

Version
1.0.0
Author
Frank Kudermann - alphanull
License
MIT
Source
SubtitleRendererIsd.js, line 13

Constructor

new SubtitleRendererIsd(player, parent)

Creates a new TTML subtitle renderer and registers it with the parent Subtitles component.

Parameters:
Name Type Description
player Player

Main player instance.

parent Subtitles

The parent Subtitles component.

Methods

canRender(cue) → boolean

Determines whether this renderer is suitable for rendering the given cue. It only renders cues that contain an isd object and no text.

Parameters:
Name Type Description
cue Object

The subtitle cue object.

Returns

True if this renderer can handle the cue, false otherwise.

Type boolean
Source
SubtitleRendererIsd.js, line 41

render(cue, currentCues)

Renders a TTML subtitle cue to the DOM using DomSmith. The rendered node is stored in the currentCues map, so it can be removed later.

Parameters:
Name Type Description
cue Object

The subtitle cue to render.

currentCues Map

Map of active cues to DOM elements.

Source
SubtitleRendererIsd.js, line 53

private #renderIsd(contents) → Array

Recursively converts ISD (Intermediate Synchronic Document) structure into a DOMSmith node tree. Currently only supports div, p, span, and br elements with optional text content.

Parameters:
Name Type Description
contents Array

The TTML ISD contents array.

Returns

Array of DomSmith node descriptors.

Type Array
Source
SubtitleRendererIsd.js, line 71

clear()

Clears the current subtitle output.

Source
SubtitleRendererIsd.js, line 101

destroy()

Destroys the renderer and cleans up DOM and references.

Source
SubtitleRendererIsd.js, line 110