Subtitle Plugin

This plugin is used to display one or more Subtitles provided to the plugin. Instead of adding track elements to the video, is uses the js api to add TextTracks to the video.

If subtitles are provided using vtt-files the VttSubtitlePlugin should be used instead.

How to use

const player = new ProgressivePlayer(...);
const subtitlePlugin = new SubtitlePlugin(player);

// Define subtitles
const subtitles = [...list of subtitles];

// Add them to plugin
subtitlePlugin.addSubtitleTracks(subtitles);

// Enable subtitle track
subtitlePlugin.enableSubtitle(subtitles[0]);

// Or disable subtitle track
subtitlePlugin.disableSubtitle(subtitles[0]);

Deprecated

Use TimedTextPlugin instead. See migration guide

Hierarchy (view full)

Constructors

Properties

name: string
Name: string = SUBTITLE_PLUGIN_NAME

Accessors

  • get loaded(): boolean
  • Property that states whether this plugin considers itself ready for continued playback based on internal logic. Triggers internal event of type PlayerInternalEventType.LoadedChanged if property value was changed.

    Returns boolean

  • set loaded(loaded): void
  • Parameters

    • loaded: boolean

    Returns void

  • get muted(): boolean
  • Property that states whether this plugin considers itself muted based on internal logic. Triggers internal event of type PlayerInternalEventType.MutedChanged if property value was changed.

    Returns boolean

  • set muted(muted): void
  • Parameters

    • muted: boolean

    Returns void

  • get version(): string
  • Property describing the plugin name and version.

    Returns string

Methods

  • Add a cue to a text track

    Parameters

    • cue: SubtitleCue

      the cue to add

    • kind: TextTrackKind

      the text track kind

    • language: string

      the language of the track

    • Optional styling: Styling

      the styling of the text track

    Returns void

  • Adds an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

  • Add new or update existing subtitle tracks

    Parameters

    • subtitleTracks: Subtitle[]

      Subtitle[] tracks to add or update

    Returns Promise<void>

  • Delete a cue from a text track

    Parameters

    • cueToDelete: SubtitleCue

      the cue to delete

    • kind: TextTrackKind

      the text track kind

    • language: string

      the language of the track

    Returns void

  • Destroys the plugin and removes all subtitle track elements that it created.

    Returns void

  • Disable/Hides the subtitle track in the video if the track exists

    Parameters

    • subtitleTrack: Subtitle

      the Subtitle to disable

    Returns void

  • Enable/Shows the subtitle track in the video if the track exists

    Parameters

    • subtitleTrack: Subtitle

      the Subtitle to enable

    Returns void

  • Returns all subtitles currently added to the plugin

    Returns Subtitle[]

    a Subtitle[] that contains all existing subtitles in the plugin

  • Plugin actions are optional and by default a plugin does not contain any actions.

    Returns PluginAction[]

  • Alias method for removeEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

  • Alias method for addEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

  • Removes all subtitles from the plugin

    Returns void

  • Removes an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

  • Removes all provided subtitles from the plugin

    Parameters

    • subtitlesToRemove: Subtitle[]

      Subtitle[] object with all subtitles that should be removed

    Returns void

  • Set global offset that will be applied to all subtitles.

    Parameters

    • offset: number

      the number in seconds describing how mow much offset all subtitles should have.

    Returns Promise<void>

  • Set global styling properties that will be applied to all subtitles.

    Parameters

    Returns void

  • Update one specific cue in a track

    Parameters

    • updatedCue: SubtitleCue

      the updated cue

    • kind: TextTrackKind

      the text track kind

    • language: string

      the language of the track

    • Optional styling: Styling

      the styling of the text track

    Returns void