--- title: HTMLMediaElement.audioTracks slug: Web/API/HTMLMediaElement/audioTracks translation_of: Web/API/HTMLMediaElement/audioTracks ---
{{APIRef("HTML DOM")}}

 HTMLMediaElement.audioTracks 获得可用音频轨道的数量

语法

audio|video.audioTracks

返回值

AudioTrackList    对象 表示音频/视频的可用音频轨道

用例

以audio标签为例

<audio id='audio'></audio>

调用

myVid=document.getElementById("audio");
alert(myVid.audioTracks.length);

参考文档

Specification Status Comment
{{SpecName('HTML WHATWG', "the-video-element.html#htmlmediaelement", "HTMLMediaElement.audioTracks")}} {{Spec2('HTML WHATWG')}} No change from {{SpecName('HTML5 W3C')}}

{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.audioTracks")}}

{{Spec2('HTML5 W3C')}} Initial definition.

浏览器支持

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
audioTracks property {{CompatUnknown}} {{CompatGeckoDesktop("33.0")}}[5] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
audioTracks property {{CompatUnknown}} {{CompatGeckoMobile("33.0")}}[5] {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

还可以看看