MediaSource.removeSourceBuffer()

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

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

Syntax

mediaSource.removeSourceBuffer(sourceBuffer);

Parameters

sourceBuffer

The SourceBuffer object to be removed.

Return value

undefined

Exceptions

NotFoundError DOMException

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

Examples

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

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

Specifications

Specification
Media Source Extensions™
# dom-mediasource-removesourcebuffer

Browser compatibility

BCD tables only load in the browser

See also