HTML DOM Video buffered 屬性
HTML DOM Video buffered 屬性返回一個 TimeRanges 物件,其中包含影片緩衝區長度及其開始、結束位置的資訊。
語法
以下是語法 −
返回 TimeRanges 物件
mediaObject.buffered
讓我們來看一個 Video buffered 屬性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video buffered</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-buffered</legend>
<video id="demo" width="320" controls><source src="https://tutorialspoint.tw/html5/foo.mp4" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="Get Buffered Seconds">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var demo = document.getElementById("demo");
demo.buffered = true;
function getTrackDetails() {
divDisplay.textContent = 'Buffered: '+demo.buffered.end(0)+' seconds';
}
</script>
</body>
</html>輸出
在不播放影片的情況下單擊 ‘獲取緩衝秒數’ 按鈕 −

播放影片後單擊 ‘獲取緩衝秒數’ 按鈕 −

廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP