The MediaSource interface of the Media Source Extensions API represents a source of media data for an HTMLMediaElement object.

MDN Reference

interface MediaSource {
    activeSourceBuffers: SourceBufferList;
    duration: number;
    onsourceclose: ((this: MediaSource, ev: Event) => any) | null;
    onsourceended: ((this: MediaSource, ev: Event) => any) | null;
    onsourceopen: ((this: MediaSource, ev: Event) => any) | null;
    readyState: ReadyState;
    sourceBuffers: SourceBufferList;
    addEventListener<K extends keyof MediaSourceEventMap>(
        type: K,
        listener: (this: MediaSource, ev: MediaSourceEventMap[K]) => any,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addSourceBuffer(type: string): SourceBuffer;
    clearLiveSeekableRange(): void;
    dispatchEvent(event: Event): boolean;
    endOfStream(error?: EndOfStreamError): void;
    removeEventListener<K extends keyof MediaSourceEventMap>(
        type: K,
        listener: (this: MediaSource, ev: MediaSourceEventMap[K]) => any,
        options?: boolean | EventListenerOptions,
    ): void;
    removeEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | EventListenerOptions,
    ): void;
    removeSourceBuffer(sourceBuffer: SourceBuffer): void;
    setLiveSeekableRange(start: number, end: number): void;
}
Hierarchy
  • EventTarget
    • MediaSource
Index

Properties

activeSourceBuffers: SourceBufferList

The activeSourceBuffers read-only property of the containing a subset of the SourceBuffer objects contained within providing the selected video track, enabled audio tracks, and shown/hidden text tracks.

MDN Reference

duration: number

The duration property of the MediaSource interface gets and sets the duration of the current media being presented.

MDN Reference

onsourceclose: ((this: MediaSource, ev: Event) => any) | null
onsourceended: ((this: MediaSource, ev: Event) => any) | null
onsourceopen: ((this: MediaSource, ev: Event) => any) | null
readyState: ReadyState

The readyState read-only property of the current MediaSource.

MDN Reference

sourceBuffers: SourceBufferList

The sourceBuffers read-only property of the containing the list of SourceBuffer objects associated with this MediaSource.

MDN Reference

Methods

  • The addSourceBuffer() method of the given MIME type and adds it to the MediaSource's SourceBuffer is also returned.

    MDN Reference

    Parameters

    • type: string

    Returns SourceBuffer

  • The clearLiveSeekableRange() method of the to MediaSource.setLiveSeekableRange().

    MDN Reference

    Returns void

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • The endOfStream() method of the js-nolint endOfStream() endOfStream(endOfStreamError) - endOfStreamError MISSING: optional_inline] - : A string representing an error to throw when the end of the stream is reached.

    MDN Reference

    Parameters

    Returns void

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

    MDN Reference

    Type Parameters

    Parameters

    Returns void

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

    MDN Reference

    Parameters

    Returns void

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

    MDN Reference

    Parameters

    Returns void

  • The setLiveSeekableRange() method of the media element.

    MDN Reference

    Parameters

    • start: number
    • end: number

    Returns void