Class: shaka.media.RegionObserver

Constructor

new RegionObserver(timelinenon-null, startsPastZero)

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 Description
timeline shaka.media.RegionTimeline
startsPastZero boolean
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:

oldPosition_ :Map.<shaka.extern.TimelineRegionInfo, 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 shaka.extern.TimelineRegionInfo
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 shaka.extern.TimelineRegionInfo
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(shaka.extern.TimelineRegionInfo, boolean)
Source: