SourceBufferList

Draft: This page is not complete.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The SourceBufferList interface represents a simple container list for multiple SourceBuffer objects.

The source buffer list containing the SourceBuffers appended to a particular MediaSource can be retrieved using the MediaSource.sourceBuffers property.

The individual source buffers can be accessed using the array operator [].

Properties

SourceBufferList.length Read only

Returns the number of SourceBuffer objects in the list.

Event handlers

SourceBufferList.onaddsourcebuffer

The event handler for the addsourcebuffer event.

SourceBufferList.onremovesourcebuffer

The event handler for the removesourcebuffer event.

Methods

Inherits methods from its parent interface, EventTarget.

Examples

This example shows how to access the active source buffers of the MediaSource connected to an already playing HTMLVideoElement.

// Video is an already playing video using a MediaSource srcObject
var video = document.querySelector('video');
var mediaSource = video.srcObject;
var sourceBufferList = mediaSource.activeSourceBuffers;
for (var i = 0; i < sourceBufferList.length; i++) {
  var sourceBuffer = sourceBufferList[i];
  // Do something with each SourceBuffer, such as call abort()
  sourceBuffer.abort();
}

Specifications

Specification
Media Source Extensions™
# sourcebufferlist

Browser compatibility

BCD tables only load in the browser

See also