W3cubDocs

/Web APIs

SourceBufferList

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 bracket notation [].

EventTarget SourceBufferList

Instance properties

SourceBufferList.length Read only

Returns the number of SourceBuffer objects in the list.

Instance methods

Inherits methods from its parent interface, EventTarget.

Events

addsourcebuffer

Fired when a SourceBuffer is added to the list.

removesourcebuffer

Fired when a SourceBuffer is removed from the list.

Examples

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

js

// Video is an already playing video using a MediaSource srcObject
const video = document.querySelector("video");
const mediaSource = video.srcObject;
const sourceBufferList = mediaSource.activeSourceBuffers;
for (const sourceBuffer of sourceBufferList) {
  // Do something with each SourceBuffer, such as call abort()
  sourceBuffer.abort();
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
SourceBufferList 3123–31 12 42
11Only works on Windows 8+.
15 8 4.4.34.4–4.4.3 3125–31 41 14
13Exposed in Mobile Safari on iPad but not on iPhone.
3.02.0–3.0
addsourcebuffer_event 53
31–53The onaddsourcebuffer event handler property is not supported.
17
12–17The onaddsourcebuffer event handler property is not supported.
42
11Only works on Windows 8+.
40
18–40The onaddsourcebuffer event handler property is not supported.
10.1
8–10.1The onaddsourcebuffer event handler property is not supported.
53
4.4.3–53The onaddsourcebuffer event handler property is not supported.
53
31–53The onaddsourcebuffer event handler property is not supported.
41 41
18–41The onaddsourcebuffer event handler property is not supported.
13Exposed in Mobile Safari on iPad but not on iPhone.
6.0
2.0–6.0The onaddsourcebuffer event handler property is not supported.
length 23 12 42
11Only works on Windows 8+.
15 8 4.4.3 33 41 14
13Exposed in Mobile Safari on iPad but not on iPhone.
3.0
removesourcebuffer_event 53
31–53The onremovesourcebuffer event handler property is not supported.
17
12–17The onremovesourcebuffer event handler property is not supported.
42
11Only works on Windows 8+.
40
18–40The onremovesourcebuffer event handler property is not supported.
10.1
8–10.1The onremovesourcebuffer event handler property is not supported.
53
4.4.3–53The onremovesourcebuffer event handler property is not supported.
53
31–53The onremovesourcebuffer event handler property is not supported.
41 41
18–41The onremovesourcebuffer event handler property is not supported.
13Exposed in Mobile Safari on iPad but not on iPhone.
6.0
2.0–6.0The onremovesourcebuffer event handler property is not supported.

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SourceBufferList