Audio/Video

Audio/Video 方法

addTextTrack() canPlayType() load() play() pause()

Audio/Video 属性

audioTracks autoplay buffered controller controls crossOrigin currentSrc currentTime defaultMuted defaultPlaybackRate duration ended error loop mediaGroup muted networkState paused playbackRate played readyState readyState seekable seeking src startDate textTracks videoTracks volume

Audio/Video 事件

onabort oncanplay oncanplaythrouth ondurationchange emptied onended onerror onloadeddata onloadedmetadata onloadstart onpause onplay onplaying onprogress onratechange onseeked onseeking onstalled onsuspend ontimeupdate onvolumechange onwaiting

JavaScript对象

基础内容

基础

HTML DOM

DOM Document DOM Elements DOM Attributes DOM Events

浏览器BOM

Window Navigator Screen History Location

html对象

a abbr address area article aside audio b base bdo blockquote body br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1~h6 head hr html i iframe img input button input checkbox input color input date input datetime input datetime-local input email input file input hidden input image input month input number input password input radio input range input reset input search input submit input text input time input url input week ins kbd keygen label legend li link map mark menu meta meter nav object ol optgroup option output p param pre progress q s samp script scetion select small source span strong style

videoTracks属性;返回代表可用视频字幕的VideoTrackList对象

使用videoTracks属性返回代表可用视频字幕的VideoTrackList对象,VideoTrackList对象表示可用视频轨道,每个可用视频 对应一个VideoTrack对象。

相关内容,html5中的video元素

属性值及其说明
说明
VideoTrackList对象 表示视频的可用视频轨道,VideoTrackList对象的属性:
  • VideoTracks.length:获取视频中可用视频轨道的数量
  • VideoTracks.getTrackById(id):使用id获得VideoTrack对象的视频轨道。
  • VideoTracks[index]:通过矩阵索引号获取VideoTrack对象
  • VideoTracks.selectedIndex:获得当前VideoTrack对象的矩阵索引号
注:index从0开始
VideoTrack对象 表示一个视频轨道,TextTrck对象的属性值:
  • id:获得视频轨道的id。
  • kind:获取视频轨道的类型(如:alternative,captions, main, sign, subtitles, commentary, 或者"" (空字符)。
  • label:获取视频轨道的标签
  • language:获取视频的语言
  • selected:获得或设置视频轨道是否动作(true/false)
JavaScript 语法:video.videoTracks

使用例


<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<button onclick="myFunction()" type="button">获取可用视频的数量</button><br>

<video id="video1" width="480" height="270" controls="controls">

<source src="material/sample.mp4" type="video/mp4"/>

<source src="material/sample.ogv" type="video/ogg"/>

你的浏览器不支持HTML5 video.

</video>

<script>

var vid = document.getElementById("video1");

function myFunction() {

alert(vid.VideoTracks.length);

}

</script>

</body>

</html>

不同浏览器的对应情况

属性
videoTracks X X X X X