TimeRanges: start() 方法
TimeRanges 接口的 start() 方法返回指定时间范围开始的时间偏移量(以秒为单位)。
语法
js
start(index)
参数
index-
要返回开始时间的范围编号。
返回值
一个数字。
异常
IndexSizeErrorDOMException-
如果指定的索引与现有范围不对应,则会抛出此异常。
示例
给定一个 ID 为“myVideo”的视频元素
js
const v = document.getElementById("myVideo");
const buf = v.buffered;
const numRanges = buf.length;
if (buf.length === 1) {
// only one range
if (buf.start(0) === 0 && buf.end(0) === v.duration) {
// The one range starts at the beginning and ends at
// the end of the video, so the whole thing is loaded
}
}
此示例查看时间范围,并检查是否已加载整个视频。
规范
| 规范 |
|---|
| HTML # dom-timeranges-start-dev |
浏览器兼容性
加载中…