Skip to content

Latest commit

 

History

History
57 lines (44 loc) · 4.25 KB

File metadata and controls

57 lines (44 loc) · 4.25 KB

TextTrack

Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: MediaTrack
Source: JSObjects/TextTrack.cs
MDN Reference: TextTrack on MDN

The TextTrack interface of the WebVTT API represents a text track associated with a media element. https://developer.mozilla.org/en-US/docs/Web/API/TextTrack

Properties

Property Type Access Description
ActiveCues TextTrackCueList get A TextTrackCueList object listing the currently active set of text track cues. Track cues are active if the current playback position of the media is between the cues' start and end times. Thus, for displayed cues such as captions or subtitles, the active cues are currently being displayed.
Cues TextTrackCueList get A TextTrackCueList which contains all of the track's cues.
Id string get A string which identifies the track, if it has one. If it doesn't have an ID, then this value is an empty string (""). If the TextTrack is associated with a <track> element, then the track's ID matches the element's ID.
InBandMetadataTrackDispatchType string get Returns a string which indicates the track's in-band metadata track dispatch type.
Kind string get Returns a string indicating what kind of text track the TextTrack describes. It must be one of the permitted values.
Label string get A human-readable string which contains the text track's label, if one is present; otherwise, this is an empty string (""), in which case a custom label may need to be generated by your code using other attributes of the track, if the track's label needs to be exposed to the user.
Language string get A string specifying the language in which the text track's contents is written. The value must be a valid BCP 47 language tag, for example "en-US" for United States English or "pt-BR" for Brazilian Portuguese.
Mode string get A string specifying the track's current mode, which must be one of the permitted values. Changing this property's value changes the track's current mode to match. The default is disabled, unless the <track> element's default boolean attribute is set to true - in which case the default mode is showing.
SourceBuffer SourceBuffer? get The SourceBuffer that created the track. Returns null if the track was not created by a SourceBuffer or the SourceBuffer has been removed from the MediaSource.sourceBuffers attribute of its parent media source.
Regions VTTRegionList get Returns a VTTRegionList object containing all of the track's regions.

Methods

Method Return Type Description
AddCue(TextTrackCue cue) void Adds a cue (specified as a TextTrackCue object) to the track's list of cues.
RemoveCue(TextTrackCue cue) void Removes a cue (specified as a TextTrackCue object) from the track's list of cues.
AddRegion(VTTRegion region) void Adds a region (specified as a VTTRegion object) to the track's list of regions.
RemoveRegion(VTTRegion region) void Removes a region (specified as a VTTRegion object) from the track's list of regions.

Events

Event Type Description
OnCueChange ActionEvent<Event> Fired when cues are entered and exited. A given text cue appears when the cue is entered and disappears when the cue is exited. Also available via the oncuechange property.

Examples

SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:

  • Properties and methods use PascalCase (e.g., readyState becomes ReadyState)
  • Events use ActionEvent with +=/-= (e.g., addEventListener("click", fn) becomes OnClick += handler)
  • Async methods return Task<T> instead of Promise<T>
  • Objects should be disposed with using statements
  • Access via JS.Get<TextTrack>(...) or constructor new TextTrack(...)
let video = document.querySelector("video");
let track = video.addTextTrack("captions", "Captions", "en");
track.mode = "showing";

See full example on MDN