as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

MediaSource

Implements the MediaSource interface. It uses EventEmitter to emit events. Maintains a list of SourceBuffers object and Active Source buffers.

Extends

Implements

Constructors

new MediaSource()

new MediaSource(): MediaSource

Returns

MediaSource

Overrides

EventAttributes.constructor

Accessors

activeSourceBuffers

Get Signature

get activeSourceBuffers(): SourceBufferList

Gets the active source buffers of mediasource. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-activesourcebuffers.

Returns

SourceBufferList

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-activesourcebuffers.

Implementation of

MediaSourceInterface.activeSourceBuffers


duration

Get Signature

get duration(): number

Gets the duraton of the content. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-duration.

Returns

number

Set Signature

set duration(duration): void

Sets the duraton of the content. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-duration.

Parameters
duration

number

Returns

void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-duration.

Implementation of

MediaSourceInterface.duration


onsourceclose

Set Signature

set onsourceclose(listener): void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-onsourceclose

Parameters
listener

EventListener

Returns

void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-onsourceclose

Implementation of

MediaSourceInterface.onsourceclose


onsourceended

Set Signature

set onsourceended(listener): void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-onsourceended

Parameters
listener

EventListener

Returns

void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-onsourceended

Implementation of

MediaSourceInterface.onsourceended


onsourceopen

Set Signature

set onsourceopen(listener): void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-onsourceopen

Parameters
listener

EventListener

Returns

void

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-onsourceopen

Implementation of

MediaSourceInterface.onsourceopen


readyState

Get Signature

get readyState(): ReadyState

Gets the ready state of MediaSource. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-readystate.

Returns

ReadyState

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-readystate.

Implementation of

MediaSourceInterface.readyState


sourceBuffers

Get Signature

get sourceBuffers(): SourceBufferList

Gets the source buffers added to the media source. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-sourcebuffers.

Returns

SourceBufferList

For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-sourcebuffers.

Implementation of

MediaSourceInterface.sourceBuffers

Methods

addEventListener()

addEventListener(type, listener, options?): void

Adds an event listener.

Parameters

type

string

The event to listen to.

listener

EventListener

The Event Handler function.

options?

Ignore.

boolean AddEventListenerOptions

Returns

void

Implementation of

MediaSourceInterface.addEventListener


addSourceBuffer()

addSourceBuffer(type): SourceBuffer

Adds a SourceBuffer to the media source based on mime type. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-addsourcebuffer.

Parameters

type

string

The mime type of data sent to source buffer.

Returns

SourceBuffer

Implementation of

MediaSourceInterface.addSourceBuffer


clearLiveSeekableRange()

clearLiveSeekableRange(): void

Clears the previously set live seek range. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-clearliveseekablerange.

Returns

void

Implementation of

MediaSourceInterface.clearLiveSeekableRange


endOfStream()

endOfStream(error?): void

Signals the end of stream for media source. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-endofstream.

Parameters

error?

EndOfStreamError

(optional) EndOfStreamError

Returns

void

Implementation of

MediaSourceInterface.endOfStream


getMaxSupportedResolution()

getMaxSupportedResolution(mimestr): Resolution

Get max supported resolution based on the decoder profile.

Parameters

mimestr

string

Returns

Resolution


removeEventListener()

removeEventListener(type, listener, options?): void

Removes an event listener.

Parameters

type

string

The event to listen to.

listener

EventListener

The Event Handler function to be removed.

options?

Ignore.

boolean EventListenerOptions

Returns

void

Implementation of

MediaSourceInterface.removeEventListener


removeSourceBuffer()

removeSourceBuffer(sourceBuffer): void

Removes the source buffer from media source. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-removesourcebuffer.

Parameters

sourceBuffer

SourceBuffer

source buffer instance to be removed.

Returns

void

Implementation of

MediaSourceInterface.removeSourceBuffer


setLiveSeekableRange()

setLiveSeekableRange(start, end): void

Sets the start and end seek range for live. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-setliveseekablerange.

Parameters

start

number

Start position of the seek range of a live content in seconds.

end

number

End position of the seek range of a live content in seconds.

Returns

void

Implementation of

MediaSourceInterface.setLiveSeekableRange


isTypeSupported()

static isTypeSupported(type): boolean

Checks whehter the mime type is supported by the Media source. For additional information, see https://www.w3.org/TR/media-source-2/#dom-mediasource-istypesupported.

Parameters

type

string

mime type.

Returns

boolean


Last updated: Sep 30, 2025