HTML DOM Video textTracks 属性返回一个 TextTrackList 对象,其中包含有关视频文本轨道的信息。
用法
以下是语法 -
返回 TextTracksList 对象
mediaObject.textTracks
让我们看一个例子Video textTracks属性 -
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video textTracks</title>
<style>
* {
padding:2px;
margin:5px;
}
form {
width:70%;
margin:0 auto;
text-align:center;
}
input[type="button"] {
border-radius:10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Video-textTracks</legend>
<video id="demo" width="320" controls>
<source src="http://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4">
<track default kind="subtitles" srclang="en" src="sample-en.srt" label="English"/>
<track kind="subtitles" srclang="es" src="sample-es.srt" label="Spanish" />
</video><br>
<input type="button" onclick="getTrackDetails()" value="Get Total Text Tracks">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var textSelect = document.getElementById("textSelect");
var demo = document.getElementById("demo");
function getTrackDetails() {
divDisplay.textContent = 'Total text tracks '+demo.textTracks.length;
divDisplay.textContent += ', 1. '+demo.textTracks[0].label;
divDisplay.textContent += ', 2. '+demo.textTracks[1].label;
}
</script>
</body>
</html>
输出
点击前‘Get Total Text Tracks’按钮 -
点击后‘Get Total Text Tracks’按钮 -
相关用法
- HTML DOM Video canPlayType()用法及代码示例
- HTML DOM Video volume属性用法及代码示例
- HTML DOM Video seekable属性用法及代码示例
- HTML DOM Video played属性用法及代码示例
- HTML DOM Video networkState属性用法及代码示例
- HTML DOM Video muted属性用法及代码示例
- HTML DOM Video paused属性用法及代码示例
- HTML DOM Video height属性用法及代码示例
- HTML DOM Video defaultMuted属性用法及代码示例
- HTML DOM Video controls属性用法及代码示例
- HTML DOM Video width属性用法及代码示例
- HTML DOM Video readyState属性用法及代码示例
- HTML DOM Video seeking属性用法及代码示例
- HTML DOM Video loop属性用法及代码示例
- HTML DOM Video duration属性用法及代码示例
- HTML DOM Video load()用法及代码示例
- HTML DOM Video playbackRate属性用法及代码示例
- HTML DOM Video ended属性用法及代码示例
- HTML DOM Video poster属性用法及代码示例
- HTML DOM Video play()用法及代码示例
注:本文由纯净天空筛选整理自AmitDiwan大神的英文原创作品 HTML DOM Video textTracks Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。