---
title: "SourceBufferList | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

# Interface SourceBufferList

The **`SourceBufferList`** interface represents a simple container list for multiple SourceBuffer objects.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/SourceBufferList)

interface SourceBufferList {  
    [length](#length): number;  
    [onaddsourcebuffer](#onaddsourcebuffer): ((this: SourceBufferList, ev: Event) \=> any) | null;  
    [onremovesourcebuffer](#onremovesourcebuffer): ((this: SourceBufferList, ev: Event) \=> any) | null;  
    ["\[iterator\]"](#iterator-1)(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<[SourceBuffer](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBuffer/)\>;  
    [addEventListener](#addeventlistener-1)<[K](#addeventlistenerk) extends keyof [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: SourceBufferList, ev: [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\[[K](#addeventlistenerk)\]) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [addEventListener](#addeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [removeEventListener](#removeeventlistener-1)<[K](#removeeventlistenerk) extends keyof [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: SourceBufferList, ev: [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\[[K](#removeeventlistenerk)\]) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [removeEventListener](#removeeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void;  
    \[index: number\]: [SourceBuffer](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBuffer/);  
}

#### Hierarchy

-   EventTarget
    -   SourceBufferList

#### Indexable

-   \[index: number\]: [SourceBuffer](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBuffer/)
    

##### Index

### Properties[](#properties)

[length](#length) [onaddsourcebuffer](#onaddsourcebuffer) [onremovesourcebuffer](#onremovesourcebuffer)

### Methods[](#methods)

[\[iterator\]](#iterator) [addEventListener](#addeventlistener) [dispatchEvent](#dispatchevent) [removeEventListener](#removeeventlistener)

## Properties[](#properties-1)

### `Readonly`length[](#length)

length: number

The **`length`** read-only property of the SourceBufferList interface returns the number of SourceBuffer objects in the list.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/SourceBufferList/length)

### onaddsourcebuffer[](#onaddsourcebuffer)

onaddsourcebuffer: ((this: SourceBufferList, ev: Event) \=> any) | null

### onremovesourcebuffer[](#onremovesourcebuffer)

onremovesourcebuffer: ((this: SourceBufferList, ev: Event) \=> any) | null

## Methods[](#methods-1)

### \[iterator\][](#iterator)

-   "\[iterator\]"(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<[SourceBuffer](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBuffer/)\>[](#iterator-1)
    
    #### Returns [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<[SourceBuffer](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBuffer/)\>
    

### addEventListener[](#addeventlistener)

-   addEventListener<[K](#addeventlistenerk) extends keyof [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: SourceBufferList, ev: [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\[[K](#addeventlistenerk)\]) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-1)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Type Parameters
    
    -   K extends keyof [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)
    
    #### Parameters
    
    -   type: [K](#addeventlistenerk)
    -   listener: (this: SourceBufferList, ev: [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\[[K](#addeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    
-   addEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-2)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    

### dispatchEvent[](#dispatchevent)

-   dispatchEvent(event: Event): boolean[](#dispatchevent-1)
    
    The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
    
    #### Parameters
    
    -   event: Event
    
    #### Returns boolean
    
    Inherited from EventTarget.dispatchEvent
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener<[K](#removeeventlistenerk) extends keyof [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: SourceBufferList, ev: [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\[[K](#removeeventlistenerk)\]) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-1)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Type Parameters
    
    -   K extends keyof [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)
    
    #### Parameters
    
    -   type: [K](#removeeventlistenerk)
    -   listener: (this: SourceBufferList, ev: [SourceBufferListEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SourceBufferListEventMap/)\[[K](#removeeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
    
-   removeEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-2)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
