Class: shaka.media.PlayRateController

Constructor

new PlayRateController(harness)

Parameters:
Name Type Description
harness shaka.media.PlayRateController.Harness
Implements:
Source:

Members

(private) isBuffering_ :boolean

Type:
  • boolean
Source:

(private) pollRate_ :number

Type:
  • number
Source:

(private) rate_ :number

Type:
  • number
Source:

Methods

(private) apply_()

Reapply the effects of |this.rate_| and |this.active_| to the media element. This will only update the rate via the harness if the desired rate has changed.
Source:

(private) applyRate_(newRate) → {boolean}

If the new rate is different than the media element's playback rate, this will change the playback rate. If the rate does not need to change, it will not be set. This will avoid unnecessary ratechange events.
Parameters:
Name Type Description
newRate number
Source:
Returns:
Type
boolean

(private) calculateCurrentRate_() → {number}

Calculate the rate that the controller wants the media element to have based on the current state of the controller.
Source:
Returns:
Type
number

getActiveRate() → {number}

Get the rate that the user will experience. This means that if we are using trick play, this will report the trick play rate. If we are buffering, this will report zero. If playback is occurring as normal, this will report 1.
Source:
Returns:
Type
number

getDefaultRate() → {number}

Get the default play rate of the playback.
Source:
Returns:
Type
number

(export) release()

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

set(rate)

Set the playback rate. This rate will only be used as provided when the player is not buffering. You should never set the rate to 0.
Parameters:
Name Type Description
rate number
Source:

setBuffering(isBuffering)

Sets the buffering flag, which controls the effective playback rate.
Parameters:
Name Type Description
isBuffering boolean If true, forces playback rate to 0 internally.
Source:

Type Definitions

Harness

A layer of abstraction between the controller and what it is controlling. In tests this will be implemented with spies. In production this will be implemented using a media element.
Type:
  • {getRate: function(): number, getDefaultRate: function(): number, setRate: function(number), movePlayhead: function(number)}
Properties:
Name Type Description
getRate function Get the current playback rate being seen by the user.
getDefaultRate function Get the default playback rate that the user should see.
setRate function Set the playback rate that the user should see.
movePlayhead function Move the playhead N seconds. If N is positive, the playhead will move forward abs(N) seconds. If N is negative, the playhead will move backwards abs(N) seconds.
Source: