LiveTracker

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

Constructor

new LiveTracker(player, optionsopt)

Creates an instance of this class.

Parameters:
NameTypeAttributesDescription
playerPlayer

The Player that this class should be attached to.

optionsObject<optional>

The key/value store of player options.

Properties
NameTypeAttributesDefaultDescription
trackingThresholdnumber<optional>
20

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

liveTolerancenumber<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 whether 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:

Whether playback is at the live edge

Type: 
boolean

behindLiveEdge() → {boolean}

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

Returns:

If we are behind the live edge

Type: 
boolean

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.

isLive() → {boolean}

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

Returns:

Whether liveTracker is tracking

Type: 
boolean

isTracking()

Whether live tracker is currently tracking or not.

liveCurrentTime() → {number}

get what we expect the live current time to be

Returns:

The expected live current time

Type: 
number

liveWindow() → {number}

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

Returns:

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

Type: 
number

nextSeekedFromUser()

The next seeked event is from the user. Meaning that any seek

2s behind live will be considered behind live for real and liveTolerance will be ignored.

pastSeekEnd() → {number}

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

Returns:

Seconds past the current seekable end

Type: 
number

reset_()

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

seekToLiveEdge()

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

seekableEnd() → {number}

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

Returns:

The furthest seekable end or Infinity.

Type: 
number

seekableStart() → {number}

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

Returns:

The earliest seekable start or 0.

Type: 
number

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