AudioTrackList

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.

特性

This interface also inherits properties from its parent interface, EventTarget .

length 只读
The number of tracks in the list.

事件处理程序

onaddtrack
An event handler to be called when the addtrack event is fired, indicating that a new audio track has been added to the media element.
onchange
An event handler to be called when the change event occurs. This occurs when one or more tracks have been enabled or disabled by their enabled flag being changed.
onremovetrack
An event handler to call when the removetrack event is sent, indicating that an audio track has been removed from the media element.

方法

This interface also inherits methods from its parent interface, EventTarget .

getTrackById()
返回 AudioTrack found within the AudioTrackList whose id matches the specified string. If no match is found, null 被返回。

Events

addtrack
Fired when a new audio track has been added to the media element.
Also available via the onaddtrack 特性。
change
Fired when a track has been enabled or disabled.
Also available via the onchange 特性。
removetrack
Fired when a new audio track has been removed from the media element.
Also available via the onremovetrack 特性。

Usage notes

In addition to being able to obtain direct access to the audio tracks present on a media element, AudioTrackList lets you set event handlers on the addtrack and removetrack events, so that you can detect when tracks are added to or removed from the media element's stream. See onaddtrack and onremovetrack for details and examples.

范例

Getting a media element's audio track list

To get a media element's AudioTrackList , use its audioTracks 特性。

var audioTracks = document.querySelector("video").audioTracks;
					

Monitoring track count changes

In this example, we have an app that displays information about the number of channels available. To keep it up to date, handlers for the addtrack and removetrack events are set up.

audioTracks.onaddtrack = updateTrackCount;
audioTracks.onremovetrack = updateTrackCount;
function updateTrackCount(event) {
  trackCount = audioTracks.length;
  drawTrackCountIndicator(trackCount);
}
					

规范

规范 状态 Comment
HTML Living Standard
The definition of 'AudioTrackList' in that specification.
实时标准
HTML5
The definition of 'AudioTrackList' in that specification.
Recommendation

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
AudioTrackList Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
addtrack event Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
change event Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
getTrackById Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
length Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
onaddtrack Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
onchange Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
onremovetrack Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No
removetrack event Chrome 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 79
Disabled
79
Disabled
Disabled From version 79: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
不支持 12 — 79
Firefox 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 10 Opera 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari 6.1 WebView Android 45 Chrome Android 45
Disabled
45
Disabled
Disabled From version 45: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 33
Disabled
33
Disabled
Disabled From version 33: this feature is behind the media.track.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 32
Disabled
32
Disabled
Disabled From version 32: this feature is behind the enable-experimental-web-platform-features preference (needs to be set to enabled ).
Safari iOS 7 Samsung Internet Android No

图例

完整支持
完整支持
不支持
不支持
用户必须明确启用此特征。
用户必须明确启用此特征。
  1. AudioTrackList
  2. 特性
    1. length
    2. onaddtrack
    3. onchange
    4. onremovetrack
  3. 方法
    1. getTrackById()
  4. Events
    1. addtrack
    2. change
    3. removetrack
  5. 继承:
    1. EventTarget
  6. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. GlobalEventHandlers
    5. HTMLAnchorElement
    6. HTMLAreaElement
    7. HTMLAudioElement
    8. HTMLBRElement
    9. HTMLBaseElement
    10. HTMLBaseFontElement
    11. HTMLBodyElement
    12. HTMLButtonElement
    13. HTMLCanvasElement
    14. HTMLContentElement
    15. HTMLDListElement
    16. HTMLDataElement
    17. HTMLDataListElement
    18. HTMLDialogElement
    19. HTMLDivElement
    20. HTMLDocument
    21. HTMLElement
    22. HTMLEmbedElement
    23. HTMLFieldSetElement
    24. HTMLFormControlsCollection
    25. HTMLFormElement
    26. HTMLFrameSetElement
    27. HTMLHRElement
    28. HTMLHeadElement
    29. HTMLHeadingElement
    30. HTMLHtmlElement
    31. HTMLIFrameElement
    32. HTMLImageElement
    33. HTMLInputElement
    34. HTMLIsIndexElement
    35. HTMLKeygenElement
    36. HTMLLIElement
    37. HTMLLabelElement
    38. HTMLLegendElement
    39. HTMLLinkElement
    40. HTMLMapElement
    41. HTMLMediaElement
    42. HTMLMetaElement
    43. HTMLMeterElement
    44. HTMLModElement
    45. HTMLOListElement
    46. HTMLObjectElement
    47. HTMLOptGroupElement
    48. HTMLOptionElement
    49. HTMLOptionsCollection
    50. HTMLOutputElement
    51. HTMLParagraphElement
    52. HTMLParamElement
    53. HTMLPictureElement
    54. HTMLPreElement
    55. HTMLProgressElement
    56. HTMLQuoteElement
    57. HTMLScriptElement
    58. HTMLSelectElement
    59. HTMLShadowElement
    60. HTMLSourceElement
    61. HTMLSpanElement
    62. HTMLStyleElement
    63. HTMLTableCaptionElement
    64. HTMLTableCellElement
    65. HTMLTableColElement
    66. HTMLTableDataCellElement
    67. HTMLTableElement
    68. HTMLTableHeaderCellElement
    69. HTMLTableRowElement
    70. HTMLTableSectionElement
    71. HTMLTemplateElement
    72. HTMLTextAreaElement
    73. HTMLTimeElement
    74. HTMLTitleElement
    75. HTMLTrackElement
    76. HTMLUListElement
    77. HTMLUnknownElement
    78. HTMLVideoElement
    79. HashChangeEvent
    80. History
    81. ImageData
    82. Location
    83. MessageChannel
    84. MessageEvent
    85. MessagePort
    86. Navigator
    87. NavigatorGeolocation
    88. NavigatorID
    89. NavigatorLanguage
    90. NavigatorOnLine
    91. NavigatorPlugins
    92. PageTransitionEvent
    93. Plugin
    94. PluginArray
    95. PopStateEvent
    96. PortCollection
    97. PromiseRejectionEvent
    98. RadioNodeList
    99. Transferable
    100. ValidityState
    101. Window
    102. WindowBase64
    103. WindowEventHandlers
    104. WindowTimers