Options
All
  • Public
  • Public/Protected
  • All
Menu

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]);

Hierarchy

Index

Constructors

constructor

  • new SubtitlePlugin(player: Player, verbose?: boolean): SubtitlePlugin
  • Creates an instance of the plugin

    Parameters

    • player: Player

      The current player

    • Optional verbose: boolean

      Whether to log events or not

    Returns SubtitlePlugin

Properties

Readonly name

name: string

Static Name

Name: string = ...

Accessors

loaded

  • get loaded(): boolean
  • set loaded(loaded: boolean): void
  • 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

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

    Parameters

    • loaded: boolean

    Returns void

muted

  • get muted(): boolean
  • set muted(muted: boolean): void
  • 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

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

    Parameters

    • muted: boolean

    Returns void

version

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

    Returns string

Methods

addCue

  • addCue(cue: SubtitleCue, kind: TextTrackKind, language: string, styling?: Styling): void
  • 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

addEventListener

  • addEventListener(type: string, callback: Listener): void
  • Adds an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

addSubtitleTracks

  • addSubtitleTracks(subtitleTracks: Subtitle[]): void
  • Add new or update existing subtitle tracks

    Parameters

    • subtitleTracks: Subtitle[]

      Subtitle[] tracks to add or update

    Returns void

deleteCue

  • deleteCue(cueToDelete: SubtitleCue, kind: TextTrackKind, language: string): 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

destroy

  • destroy(): void
  • Destroys the plugin and removes all subtitle track elements that it created.

    Returns void

disableSubtitleTrack

  • disableSubtitleTrack(subtitleTrack: Subtitle): void
  • Disable/Hides the subtitle track in the video if the track exists

    Parameters

    • subtitleTrack: Subtitle

      the Subtitle to disable

    Returns void

enableSubtitleTrack

  • enableSubtitleTrack(subtitleTrack: Subtitle): void
  • Enable/Shows the subtitle track in the video if the track exists

    Parameters

    • subtitleTrack: Subtitle

      the Subtitle to enable

    Returns void

getAllSubtitleTracks

  • Returns all subtitles currently added to the plugin

    Returns Subtitle[]

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

getPluginActions

  • getPluginActions(): PluginAction[]
  • Plugin actions are optional and by default a plugin does not contain any actions.

    Returns PluginAction[]

off

  • off(type: string, callback: Listener): void
  • Alias method for removeEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

on

  • on(type: string, callback: Listener): void
  • Alias method for addEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

removeAllSubtitleTracks

  • removeAllSubtitleTracks(): void
  • Removes all subtitles from the plugin

    Returns void

removeEventListener

  • removeEventListener(type: string, callback: Listener): void
  • Removes an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

removeSubtitleTracks

  • removeSubtitleTracks(subtitlesToRemove: Subtitle[]): void
  • Removes all provided subtitles from the plugin

    Parameters

    • subtitlesToRemove: Subtitle[]

      Subtitle[] object with all subtitles that should be removed

    Returns void

setGlobalOffset

  • setGlobalOffset(offset: number): 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 void

setGlobalSubtitleStyling

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

    Parameters

    Returns void

updateCue

  • updateCue(updatedCue: SubtitleCue, kind: TextTrackKind, language: string, styling?: Styling): 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