W3cubDocs

/Web APIs

MediaSource: removeSourceBuffer() method

The removeSourceBuffer() method of the MediaSource interface removes the given SourceBuffer from the SourceBufferList associated with this MediaSource object.

Syntax

js

removeSourceBuffer(sourceBuffer)

Parameters

sourceBuffer

The SourceBuffer object to be removed.

Return value

None (undefined).

Exceptions

NotFoundError DOMException

Thrown if the supplied sourceBuffer doesn't exist in MediaSource.sourceBuffers.

Examples

js

for (let i = 0; i < 10; i++) {
  const sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
}

mediaSource.removeSourceBuffer(mediaSource.sourceBuffers[0]);

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
removeSourceBuffer 23 12 42
11Only works on Windows 8+.
15 8 4.4.3 25 41 14
13Exposed in Mobile Safari on iPad but not on iPhone.
1.5

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