Class: shaka.media.TimeRangesUtils

A set of utility functions for dealing with TimeRanges objects.

Methods

(static) 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

(static) bufferEnd(b) → (nullable) {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

(static) bufferStart(b) → (nullable) {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

(static) getBufferedInfo(b) → (non-null) {Array.<shakaExtern.BufferedRange>}

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

(static) getGapIndex(b, time) → (nullable) {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
Source:
Returns:
The index of the buffer after the gap, or null if not in a gap.
Type
number

(static) isBuffered(b, time, smallGapLimitopt) → {boolean}

Determines if the given time is inside a buffered range. This includes gaps, meaning that if the playhead is in a gap, it is considered buffered. If there is a small gap between the playhead and buffer start, consider it as buffered.
Parameters:
Name Type Attributes Description
b TimeRanges
time number Playhead time
smallGapLimit number <optional>
Set in configuration
Source:
Returns:
Type
boolean