Class: shaka.media.PlayheadObserver

Constructor

new PlayheadObserver(video, minBufferTime, config, onBuffering, onEvent, onChangePeriod, implnon-null)

This observes the current playhead position to raise events. This will only observe the playhead, shaka.media.Playhead will modify it. This will:
  • Track buffering state and call |onBuffering|.
  • Track current Period and call |onChangePeriod|.
  • Track timeline regions and raise respective events.
Parameters:
Name Type Description
video HTMLMediaElement
minBufferTime number
config shaka.extern.StreamingConfiguration
onBuffering function(boolean) Called and passed true when stopped for buffering; called and passed false when proceeding after buffering. If passed true, the callback should not set the video's playback rate.
onEvent function(!Event) Called when an event is raised to be sent to the application.
onChangePeriod function() Called when the playhead moves to a different Period.
impl shaka.media.PlayheadObserver.Implementation Some functions need to be implemented differently depending on if we are using media media source or "video.src=".
Implements:
Source:

Interfaces

Implementation

Members

(private, static) RegionLocation_ :number

Type:
  • number
Properties:
Name Value Type Description
FUTURE_REGION 1 number
INSIDE 2 number
PAST_REGION 3 number
Source:

(private, static, constant) UNDERFLOW_THRESHOLD_ :number

The threshold for underflow, in seconds. If there is less than this amount of data buffered, we will consider the player to be out of data.
Type:
  • number
Source:

(private) buffering_ :boolean

Type:
  • boolean
Source:

(private) curPeriodIndex_ :number

Type:
  • number
Source:

(private, non-null) destroyer_ :shaka.util.Destroyer

Type:
Source:

(private) minBufferTime_ :number

Type:
  • number
Source:

(private, nullable) onBuffering_ :?function(boolean)

Type:
  • ?function(boolean)
Source:

(private, nullable) onChangePeriod_ :?function()

Type:
  • ?function()
Source:

(private, nullable) onEvent_ :?function(!Event)

Type:
  • ?function(!Event)
Source:

(private, nullable) watchdogTimer_ :number

Type:
  • number
Source:

Methods

(private, static) cloneTimelineInfo_(source) → {shaka.extern.TimelineRegionInfo}

Clones the given TimelineRegionInfo so the app can modify it without modifying our internal objects.
Parameters:
Name Type Description
source shaka.extern.TimelineRegionInfo
Source:
Returns:
Type
shaka.extern.TimelineRegionInfo

addTimelineRegion(regionInfo)

Adds a new timeline region. Events will be raised whenever the playhead enters or exits the given region. This method will raise a 'timelineregionadded' event.
Parameters:
Name Type Description
regionInfo shaka.extern.TimelineRegionInfo
Source:

(private) cancelWatchdogTimer_()

Cancels the watchdog timer, if any.
Source:

(export) destroy() → (non-null) {Promise}

Request that this object be destroyed, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
Implements:
Source:
Returns:
Type
Promise

(private) onWatchdogTimer_()

Called on a recurring timer to detect buffering events and Period changes.
Source:

seeked()

Called when a seek completes.
Source:

(private) setBuffering_(buffering)

Stops the playhead for buffering, or resumes the playhead after buffering.
Parameters:
Name Type Description
buffering boolean True to stop the playhead; false to allow it to continue.
Source:

(private) startWatchdogTimer_()

Starts the watchdog timer.
Source:

(private) updateTimelineRegion_(isSeek, region)

Updates the status of a timeline region and fires any enter/exit events.
Parameters:
Name Type Description
isSeek boolean
region shaka.media.PlayheadObserver.TimelineRegion
Source:

Type Definitions

TimelineRegion

Type:
Properties:
Name Type Description
info shaka.extern.TimelineRegionInfo The info for this timeline region.
status shaka.media.PlayheadObserver.RegionLocation_ This tracks where the region is relative to the playhead. This tracks whether we are before or after the region so we can raise events if we pass it.
Source: