Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML 音频/视频 DOM audioTracks 属性

❮ HTML 音频/视频 DOM 参考

示例

获取可用音频轨道的数量

let vid = document.getElementById("myVideo");
alert(vid.audioTracks.length);
亲自试一试 »

定义和用法

audioTracks 属性返回一个 AudioTrackList 对象。

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

每个可用的音频轨道都由一个 AudioTrack 对象表示。


浏览器支持

属性
audioTracks 不支持 11 不支持 不支持 不支持

语法

audio|video.audioTracks

返回值

类型 描述
AudioTrackList 对象 表示音频/视频的可用音频轨道。

AudioTrackList 对象

  • audioTracks.length - 获取可用的音频轨道数量
  • audioTracks.getTrackById(id) - 按 id 获取 AudioTrack 对象
  • audioTracks[index] - 按索引获取 AudioTrack 对象

注意:第一个可用的 AudioTrack 对象是索引 0

AudioTrack 对象 表示音频轨道。

AudioTrack 对象属性

  • id - 获取音频轨道的 id
  • kind - 获取音频轨道的类型(可以是:"alternative"、"description"、"main"、"translation"、"commentary" 或 ""(空字符串)) 
  • label - 获取音频轨道的标签
  • language - 获取音频轨道的语言
  • enabled - 获取或设置轨道是否处于活动状态 (true|false)

❮ HTML 音频/视频 DOM 参考
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.