LiveTracker(player, optionsopt)

A class for checking live current time and determining when the player is at or behind the live edge.

new LiveTracker(player, optionsopt)

Creates an instance of this class.

Parameters:
Name Type Attributes Description
player Player

The Player that this class should be attached to.

options Object <optional>

The key/value store of player options.

Properties
Name Type Attributes Default Description
trackingThreshold number <optional>
30

Number of seconds of live window (seekableEnd - seekableStart) that media needs to have before the liveui will be shown.

liveTolerance number <optional>
15

Number of seconds behind live that we have to be before we will be considered non-live. Note that this will only be used when playing at the live edge. This allows large seekable end changes to not effect wether we are live or not.

Methods

atLiveEdge() → {boolean}

Determines if currentTime is at the live edge and won't fall behind on each seekableendchange

Returns:
boolean -

Wether playback is at the live edge

behindLiveEdge() → {boolean}

If we are currently behind the live edge, aka currentTime will be behind on a seekableendchange

Returns:
boolean -

If we are behind the live edge

dispose()

Dispose of liveTracker

handleDurationchange()

handle a durationchange event on the player and start/stop tracking accordingly.

handleFirstTimeupdate()

handle the first timeupdate on the player if it wasn't already playing when live tracker started tracking.

handlePlay()

handle the first play on the player, and make sure that we seek right to the live edge.

handleSeeked()

Keep track of what time a seek starts, and listen for seeked to find where a seek ends.

handleVisibilityChange()

toggle tracking based on document visiblility

isLive() → {boolean}

Determines if the player is live, only checks if this component is tracking live playback or not

Returns:
boolean -

Wether liveTracker is tracking

isTracking()

Wether live tracker is currently tracking or not.

liveCurrentTime() → {number}

get what we expect the live current time to be

Returns:
number -

The expected live current time

liveWindow() → {number}

Get the live time window aka the amount of time between seekable start and live current time.

Returns:
number -

The amount of seconds that are seekable in the live video.

pastSeekEnd() → {number}

The number of seconds that have occured after seekable end changed. This will be reset to 0 once seekable end changes.

Returns:
number -

Seconds past the current seekable end

reset_()

Stop tracking, and set all internal variables to their initial value.

seekableEnd() → {number}

A helper to get the player seekable end so that we don't have to null check everywhere

Returns:
number -

The furthest seekable end or Infinity.

seekableStart() → {number}

A helper to get the player seekable start so that we don't have to null check everywhere

Returns:
number -

The earliest seekable start or 0.

seekToLiveEdge()

Seek to the live edge if we are behind the live edge

startTracking()

start tracking live playback

stopTracking()

stop tracking live playback

toggleTracking()

start/stop tracking

trackLive_()

all the functionality for tracking when seek end changes and for tracking how far past seek end we should be