Class: shaka.media.RegionObserver

Constructor

new RegionObserver(timelinenon-null, startsPastZero, startPositionopt, nullable)

Create a region observer for the given timeline. The observer does not own the timeline, only uses it. This means that the observer should NOT destroy the timeline.
Parameters:
Name Type Attributes Default Description
timeline shaka.media.RegionTimeline<T>
startsPastZero boolean
startPosition number <optional>
<nullable>
null The position playback was asked to start at, if known. Regions that end at or after it are still entered when the first poll lands past them, e.g. a zero-duration region at the start of the presentation when the first frame is a little after it.
Implements:
Source:

Members

RelativePosition_ :number

An enum of relative positions between the playhead and a region. Each is phrased so that it works in "The playhead is X" where "X" is any value in the enum.
Type:
  • number
Properties:
Name Value Type Description
BEFORE_THE_REGION 1 number
IN_THE_REGION 2 number
AFTER_THE_REGION 3 number
Source:

lastPosition_ :number

The position of the previous poll or, before the first one, the start position if known.
Type:
  • number
Source:

oldPosition_ :Map<T, shaka.media.RegionObserver.RelativePosition_>

A mapping between a region and where we previously were relative to it. When the value here differs from what we calculate, it means we moved and should fire an event.
Type:
Source:

rules_ :Iterable<shaka.media.RegionObserver.Rule_>

A read-only collection of rules for what to do when we change position relative to a region.
Type:
Source:

startsPastZero_ :boolean

Whether the asset is expected to start at a time beyond 0 seconds. For example, if the asset is a live stream. If true, we will not start polling for regions until the playhead has moved past 0 seconds, to avoid bad behaviors where the current time is briefly 0 before we have enough data to play.
Type:
  • boolean
Source:

Methods

determinePositionRelativeTo_(region, seconds) → {shaka.media.RegionObserver.RelativePosition_}

Get the relative position of the playhead to |region| when the playhead is at |seconds|. We treat the region's start and end times as inclusive bounds.
Parameters:
Name Type Description
region T
seconds number
Source:
Returns:
Type
shaka.media.RegionObserver.RelativePosition_

onEvent_(eventType, region, seeking)

Dispatch events of the given type. All event types in this class have the same parameters: region and seeking.
Parameters:
Name Type Description
eventType string
region T
seeking boolean
Source:

poll(positionInSeconds, wasSeeking)

Check again (using an update playhead summary) if an event should be fired. If an event should be fired, fire it.
Parameters:
Name Type Description
positionInSeconds number
wasSeeking boolean
Implements:
Source:

release()

Request that this object release all internal references.
Inherited From:
Implements:
Source:

Type Definitions

EventListener_

All region observer events (onEnter, onExit, and onSkip) will be passed the region that the playhead is interacting with and whether or not the playhead moving is part of a seek event.
Type:
  • function(?, boolean)
Source: