HTML DOM Video preload 属性
htmlweb developmentfront end technology更新于 2024/5/26 4:28:17
HTML DOM Video preload 属性返回一个字符串,该字符串对应于创建者认为视频数据应该加载的时间。尽管有时这可能会被忽略。默认值为"metadata"。
语法
以下是语法 −
返回字符串值
mediaObject.preload
将 preload 设置为字符串
mediaObject.preload = “auto|metadata|none”
让我们看一个 HTML DOM Video preload 属性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video preload</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-preload</legend>
<video id="demo" width="320" preload=”none” controls><source
src="http://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="Preload Video">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var demo = document.getElementById("demo");
divDisplay.textContent = 'Data Savings mode on. Play video to load it';
function getTrackDetails() {
demo.preload = 'metadata'
divDisplay.textContent = 'Data Savings mode off. Preload enabled';
}
</script>
</body>
</html>
输出
点击"预加载视频"按钮之前 −

点击"预加载视频"按钮之后 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

