HTMLMediaElement.buffered

HTMLMediaElement.buffered 返回一个只读 TimeRanges 对象 返回媒体已缓冲的区域

Note: This feature is not available in Web Workers.

语法

var timeRange = audioObject.buffered

返回值

对象TimeRanges

length - 获得音频/视频中已缓冲范围的数量

buffered.start 开始的区域 

buffered.end 结束的区域

例子

var obj = document.createElement('video');
console.log(obj.buffered); // TimeRanges { length: 0 }
console.log(obj.buffered.start(0));//第一个缓存开始的区域
console.log(obj.buffered.end(0));//第一个缓存结束的区域

参考文档

Specification Status Comment
HTML Living Standard
HTMLMediaElement.buffered
Living Standard No change from HTML5
HTML5
HTMLMediaElement.buffered
Recommendation Initial definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
buffered property (Yes) 4.0 (2.0) 9 ? ?
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
buffered property (Yes) 4.0 (2.0) (Yes) ? ? ?

也可以看看