TimeRanges:length 属性
        
        
          
                Baseline
                
                  Widely available
                
                
              
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
TimeRanges.length 只读属性返回该对象中时间范围的数量。
值
一个数字。
示例
给定一个 ID 为“myVideo”的 video 元素:
js
const v = document.getElementById("myVideo");
const buf = v.buffered;
const numRanges = buf.length;
if (buf.length === 1) {
  // 只有一个范围
  if (buf.start(0) === 0 && buf.end(0) === v.duration) {
    // 这个范围从视频的开始处开始,一直到结尾结束,因此整个视频都会被加载
  }
}
这个示例检查了时间范围,并判断视频的全部内容是否已经加载完成。
规范
| Specification | 
|---|
| HTML> # dom-timeranges-length-dev> | 
浏览器兼容性
Loading…