Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: EventTarget, IEnumerable<TextTrack>
Source: JSObjects/TextTrackList.cs
MDN Reference: TextTrackList on MDN
The TextTrackList interface is used to represent a list of the text tracks defined for the associated video or audio element, with each track represented by a separate TextTrack object in the list. Text tracks can be added to a media element declaratively using the <track> element or programmatically using the HTMLMediaElement.addTextTrack() method. An instance of this object can be retrieved using the textTracks property of an HTMLMediaElement object. https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList
| Property | Type | Access | Description |
|---|---|---|---|
Length |
int |
get | Returns the number of track objects in the list. |
| Method | Return Type | Description |
|---|---|---|
GetEnumerator() |
IEnumerator<TextTrack> |
|
GetTrackById(string id) |
TextTrack? |
Returns the track found within the list whose id matches the specified string. If no match is found, null is returned. |
| Event | Type | Description |
|---|---|---|
OnAddTrack |
ActionEvent<TrackEvent> |
Fired when a new track has been added to the media element. |
OnChange |
ActionEvent<Event> |
Fired when a track has been enabled or disabled. |
OnRemoveTrack |
ActionEvent<TrackEvent> |
Fired when a track has been removed from the media element. |
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.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<TextTrackList>(...)or constructornew TextTrackList(...)
const textTracks = document.querySelector("video").textTracks;textTracks.onaddtrack = updateTrackCount;
textTracks.onremovetrack = updateTrackCount;
function updateTrackCount(event) {
trackCount = textTracks.length;
drawTrackCountIndicator(trackCount);
}