Class TextTrack
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The TextTrack interface of the WebVTT API represents a text track associated with a media element.
[Value("TextTrack")]
public class TextTrack : EventTarget
- Inheritance
-
TextTrack
- Inherited Members
Remarks
An object of this type owns the list of VTTCue objects that will be displayed over the video at various points.
TextTrack objects can be added to a HTMLVideoElement or HTMLAudioElement element using the AddTextTrack(TextTrackKind, string, string) method, which has the same effect as adding text tracks declaratively using {{htmlelement("track")}} elements inside a {{htmlelement("video")}} or {{htmlelement("audio")}} element.
The TextTrack objects are stored in a TextTrackList, which can be retrieved using the TextTracks property.
Constructors
TextTrack()
public TextTrack()
Properties
ActiveCues
The activeCues read-only property of the TextTrack interface returns a TextTrackCueList object listing the currently active cues.
[Value("activeCues")]
public TextTrackCueList? ActiveCues { get; }
Property Value
- TextTrackCueList
A TextTrackCueList object.
Remarks
Cues
The cues read-only property of the TextTrack interface returns a TextTrackCueList object containing all of the track's cues.
[Value("cues")]
public TextTrackCueList? Cues { get; }
Property Value
- TextTrackCueList
A TextTrackCueList object.
Remarks
Id
The id read-only property of the TextTrack interface returns the ID of the track if it has one.
[Value("id")]
public string Id { get; }
Property Value
- string
A string containing the ID, or an empty string.
Remarks
InBandMetadataTrackDispatchType
The inBandMetadataTrackDispatchType read-only property of the TextTrack interface returns the text track's in-band metadata dispatch type of the text track represented by the TextTrack object.
[Value("inBandMetadataTrackDispatchType")]
public string InBandMetadataTrackDispatchType { get; }
Property Value
- string
A string containing the
inBandMetadataTrackDispatchType, or an empty string.
Remarks
An in-band metadata dispatch type is a string extracted from a media resource specifically for in-band metadata tracks. An example of a media resource that might have such tracks is a TV station streaming a broadcast on the web. Text Tracks may be used to include metadata for ad targeting, additional information such as recipe data during a cooking show, or trivia game data during a game show.
The value of this attribute could be used to attach these tracks to dedicated script modules as they are loaded.
Kind
The kind read-only property of the TextTrack interface returns the kind of text track this object represents. This decides how the track will be handled by a user agent.
[Value("kind")]
public TextTrackKind Kind { get; }
Property Value
- TextTrackKind
A string. One of:
Remarks
Label
The label read-only property of the TextTrack interface returns a human-readable label for the text track, if it is available.
[Value("label")]
public string Label { get; }
Property Value
- string
A string containing the
label, or an empty string.
Remarks
Language
The language read-only property of the TextTrack interface returns the language of the text track.
[Value("language")]
public string Language { get; }
Property Value
- string
A string containing a language identifier. For example,
"en-US"for United States English or"pt-BR"for Brazilian Portuguese.
Remarks
This uses the same values as the HTML lang attribute. These values are documented in {{RFC(5646, "Tags for Identifying Languages (also known as BCP 47)")}}.
Mode
The TextTrack interface'smode property is a string specifying and controlling the
text track's mode: disabled, hidden, orshowing. You can read this value to determine the current mode,
and you can change this value to switch modes.
[Value("mode")]
public TextTrackMode Mode { get; set; }
Property Value
- TextTrackMode
A string which indicates the track's current mode. One of:
Remarks
Safari additionally requires the default
boolean attribute to be set to true when implementing your own video player controls in
order for the subtitles cues to be shown.
-WebVTT
-TextTrack
-TextTrackList
-TextTrackCueList
-VTTCue
-track
-HTMLTrackElement
Oncuechange
[Value("oncuechange")]
public EventHandlerNonNull Oncuechange { get; set; }
Property Value
SourceBuffer
The read-only sourceBuffer property of the TextTrack interface returns the
SourceBuffer that created the track, or null if the track was not
created by a SourceBuffer or the SourceBuffer has been
removed from the SourceBuffers attribute of its parent
media source.
[Value("sourceBuffer")]
public SourceBuffer? SourceBuffer { get; }
Property Value
- SourceBuffer
A SourceBuffer or null.
Remarks
Methods
AddCue(TextTrackCue)
The addCue() method of the TextTrack interface adds a new cue to the list of cues.
[Value("addCue")]
public GlobalObject.Undefined AddCue(TextTrackCue cue)
Parameters
cueTextTrackCue
Returns
- GlobalObject.Undefined
Undefined.
Remarks
RemoveCue(TextTrackCue)
The removeCue() method of the TextTrack interface removes a cue from the list of cues.
[Value("removeCue")]
public GlobalObject.Undefined RemoveCue(TextTrackCue cue)
Parameters
cueTextTrackCue
Returns
- GlobalObject.Undefined
Undefined.