Buffer API

Buffer management and monitoring

BufferConfig

Interface

Configures different kinds of buffer settings for media types defined in MediaType.

Example:

buffer: {
  [MediaType.Video]: {
    [BufferType.ForwardDuration]: 30,
    [BufferType.BackwardDuration]: 20,
  },
  [MediaType.Audio]: {
    [BufferType.ForwardDuration]: 50,
    [BufferType.BackwardDuration]: 20,
  },
},

Properties

audio

Optional audio: BufferMediaTypeConfig

Configures various settings for the audio buffers.


video

Optional video: BufferMediaTypeConfig

Configures various settings for the video buffers.


BufferLevel

Interface

Holds information about the current buffer level.

Properties

level

level: number

The amount of currently buffered data, relative to the current time of the player.
Returns null if there is no track for the associated media type.


media

media: MediaType

The media type the buffer data applies to.


targetLevel

targetLevel: number

The target buffer level the player tries to maintain for the associated media type.


type

type: BufferType

The buffer type the buffer data applies to.


BufferLevelTargets

Interface

Properties

backwardduration

backwardduration: number


forwardduration

forwardduration: number


BufferMediaTypeConfig

Interface

Properties

backwardduration

Optional backwardduration: number

The amount of data in seconds the player keeps buffered after it played over it. Default is 20.


forwardduration

Optional forwardduration: number

The amount of data in seconds the player tries to buffer in advance. Default is 40.

For live streams the lowest value of playlist duration for HLS, timeShiftBufferDepth for DASH and
this targetLevel value is used as a maximum value for the forward buffers.


BufferType

Enum

Enumeration Members

BackwardDuration

BackwardDuration = "backwardduration"

Represents the buffered data up until the current playback time.


ForwardDuration

ForwardDuration = "forwardduration"

Represents the buffered data starting at the current playback time.


PlayerBufferAPI

Interface

Methods

getLevel

getLevel(type, media): BufferLevel

Returns the current and target buffer level for the given buffer type and media type.

Parameters

NameTypeDescription
typeBufferTypethe buffer type for which to get the buffer level for.
mediaMediaTypethe media type for which to get the buffer level for.

Returns

BufferLevel

Since: v8.1


setTargetLevel

setTargetLevel(type, value, media): void

Sets the target buffer level for the chosen buffer and media type.

Parameters

NameTypeDescription
typeBufferTypeThe buffer type to change the target buffer level for.
valuenumberThe value to set.
mediaMediaTypeThe media type to change the target buffer level for.

Returns

void

Since: v8.1