files/en-us/web/api/bufferedchangeevent/bufferedchangeevent/index.md
{{APIRef("Media Source Extensions")}}{{AvailableInWorkers("window_and_dedicated")}}
The BufferedChangeEvent() constructor of the {{domxref("BufferedChangeEvent")}} interface creates a new BufferedChangeEvent object instance.
new BufferedChangeEvent(type, options)
type
BufferedChangeEvent this is always bufferedchange.options {{optional_inline}}
: An object that, in addition to the properties defined in {{domxref("Event/Event", "Event()")}}, has the following properties:
[!NOTE] Although the spec marks
optionsas optional, Safari (currently the only implementation) throws aTypeErrorif the argument is omitted entirely. Passing an empty object ({}) works correctly.
addedRanges {{optional_inline}}
removedRanges {{optional_inline}}
A new {{domxref("BufferedChangeEvent")}} object instance.
The BufferedChangeEvent() constructor isn't generally called manually. When a {{domxref("ManagedSourceBuffer")}}'s bufferedchange event fires (meaning its buffered ranges change), the browser will construct a BufferedChangeEvent object to use as the event object.
The event's properties describe what changed:
sourceBuffer.addEventListener("bufferedchange", (event) => {
console.log(event instanceof BufferedChangeEvent); // true
console.log(event.type); // "bufferedchange"
console.log(event.addedRanges); // TimeRanges — ranges added to the buffer
console.log(event.removedRanges); // TimeRanges — ranges removed from the buffer
});
{{Specifications}}
{{Compat}}