Class: shaka.media.TimeRangesUtils

A set of utility functions for dealing with TimeRanges objects.

Constructor

new TimeRangesUtils()

A set of utility functions for dealing with TimeRanges objects.

Source:

Methods

bufferedAheadOf(b, time) → {number}

Computes how far ahead of the given timestamp is buffered. To provide smooth playback while jumping gaps, we don't include the gaps when calculating this. This only includes the amount of content that is buffered.
Parameters:
Name Type Description
b TimeRanges
time number
Source:
Returns:
The number of seconds buffered, in seconds, ahead of the given time.
Type
number

bufferEnd(b) → {number}

Gets the last timestamp in the buffer.
Parameters:
Name Type Description
b TimeRanges
Source:
Returns:
The last buffered timestamp, in seconds, if |buffered| is non-empty; otherwise, return null.
Type
number

bufferStart(b) → {number}

Gets the first timestamp in the buffer.
Parameters:
Name Type Description
b TimeRanges
Source:
Returns:
The first buffered timestamp, in seconds, if |buffered| is non-empty; otherwise, return null.
Type
number

computeAddedRange(oldRanges, newRanges) → {shaka.extern.BufferedRange}

This operation can be potentially EXPENSIVE and should only be done in debug builds for debugging purposes.
Parameters:
Name Type Description
oldRanges TimeRanges
newRanges TimeRanges
Source:
Returns:
The last added range, chronologically by presentation time.
Type
shaka.extern.BufferedRange

getBufferedInfo(b) → {Array.<shaka.extern.BufferedRange>}

Parameters:
Name Type Description
b TimeRanges
Source:
Returns:
Type
Array.<shaka.extern.BufferedRange>

getGapIndex(b, time, threshold) → {number}

Determines if the given time is inside a gap between buffered ranges. If it is, this returns the index of the buffer that is *ahead* of the gap.
Parameters:
Name Type Description
b TimeRanges
time number
threshold number
Source:
Returns:
The index of the buffer after the gap, or null if not in a gap.
Type
number

isBuffered(b, time) → {boolean}

Determines if the given time is inside a buffered range.
Parameters:
Name Type Description
b TimeRanges
time number Playhead time
Source:
Returns:
Type
boolean

isBufferNegligible_(b) → {boolean}

Returns whether the buffer is small enough to be ignored.
Parameters:
Name Type Description
b TimeRanges
Source:
Returns:
Type
boolean