dom / latest / sourcebufferlist.html /

SourceBufferList

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

EventTarget SourceBufferList

Properties

SourceBufferList.length Read only

Returns the number of SourceBuffer objects in the list.

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.

// 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

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
31
23-31
12
42
11
Only works on Windows 8+.
15
8
4.4.3
4.4-4.4.3
31
25-31
41
14
13
Exposed in Mobile Safari on iPad but not on iPhone.
3.0
2.0-3.0
addsourcebuffer_event
53
31-53
The onaddsourcebuffer event handler property is not supported.
17
12-17
The onaddsourcebuffer event handler property is not supported.
42
11
Only works on Windows 8+.
40
18-40
The onaddsourcebuffer event handler property is not supported.
10.1
8-10.1
The onaddsourcebuffer event handler property is not supported.
53
4.4.3-53
The onaddsourcebuffer event handler property is not supported.
53
31-53
The onaddsourcebuffer event handler property is not supported.
41
41
18-41
The onaddsourcebuffer event handler property is not supported.
13
Exposed in Mobile Safari on iPad but not on iPhone.
6.0
2.0-6.0
The onaddsourcebuffer event handler property is not supported.
length
23
12
42
11
Only works on Windows 8+.
15
8
4.4.3
33
41
14
13
Exposed in Mobile Safari on iPad but not on iPhone.
3.0
removesourcebuffer_event
53
31-53
The onremovesourcebuffer event handler property is not supported.
17
12-17
The onremovesourcebuffer event handler property is not supported.
42
11
Only works on Windows 8+.
40
18-40
The onremovesourcebuffer event handler property is not supported.
10.1
8-10.1
The onremovesourcebuffer event handler property is not supported.
53
4.4.3-53
The onremovesourcebuffer event handler property is not supported.
53
31-53
The onremovesourcebuffer event handler property is not supported.
41
41
18-41
The onremovesourcebuffer event handler property is not supported.
13
Exposed in Mobile Safari on iPad but not on iPhone.
6.0
2.0-6.0
The onremovesourcebuffer event handler property is not supported.

See also

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