--- title: HTMLMediaElement.buffered slug: Web/API/HTMLMediaElement/buffered translation_of: Web/API/HTMLMediaElement/buffered ---
{{APIRef("HTML DOM")}}

HTMLMediaElement.buffered 返回一个只读 {{domxref("TimeRanges")}} 对象 返回媒体已缓冲的区域

Note: This feature is not available in Web Workers.

语法

var timeRange = audioObject.buffered

返回值

对象{{domxref("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
{{SpecName('HTML WHATWG', "embedded-content.html#media-elements", "HTMLMediaElement.buffered")}} {{Spec2('HTML WHATWG')}} No change from {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.buffered")}} {{Spec2('HTML5 W3C')}} Initial definition.

浏览器兼容性

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
buffered property {{CompatVersionUnknown}} {{CompatGeckoDesktop("2.0")}} {{CompatIE("9")}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
buffered property {{CompatVersionUnknown}} {{CompatGeckoMobile("2.0")}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

也可以看看