Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: EventTarget, IEnumerable<AudioTrack>
Source: JSObjects/AudioTrackList.cs
MDN Reference: AudioTrackList on MDN
The AudioTrackList interface is used to represent a list of the audio tracks contained within a given HTML media element, with each track represented by a separate AudioTrack object in the list. Retrieve an instance of this object with HTMLMediaElement.audioTracks. The individual tracks can be accessed using array syntax. https://developer.mozilla.org/en-US/docs/Web/API/AudioTrackList
| Property | Type | Access | Description |
|---|---|---|---|
Length |
int |
get | Returns the number of track objects in the list. |
| Method | Return Type | Description |
|---|---|---|
GetEnumerator() |
IEnumerator<AudioTrack> |
|
GetTrackById(string id) |
AudioTrack? |
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<AudioTrackList>(...)or constructornew AudioTrackList(...)
const audioTracks = document.querySelector("video").audioTracks;audioTracks.onaddtrack = updateTrackCount;
audioTracks.onremovetrack = updateTrackCount;
function updateTrackCount(event) {
trackCount = audioTracks.length;
drawTrackCountIndicator(trackCount);
}