Skip to content

Module: src/settings/PlaybackRate

The PlaybackRate component shows the current playback speed and also provides a UI to change it.

Version
1.0.0
Author
Frank Kudermann - alphanull
License
MIT
Requires
DomSmith
Source
PlaybackRate.js, line 11

Constructor

new PlaybackRate(player, parent)

Creates an instance of the PlaybackRate component.

Parameters:
Name Type Description
player Player

Reference to the media player instance.

parent Popup

Reference to the parent instance (In this case the settings popup).

Members

Holds the instance configuration for this component.

Properties
Name Type Attributes Default Description
allowedValues Array<number> optional [0.25, 0.5, 1, 2, 4]

This configures which playback rate speeds appear in the menu.

speed number optional 1

The initial playback speed.

Type
Object
Source
PlaybackRate.js, line 19

Reference to the main player instance.

Type
Player
Source
PlaybackRate.js, line 28

Holds tokens of subscriptions to player events, for later unsubscribe.

Type
Array<number>
Source
PlaybackRate.js, line 40

Methods

private #onMediaReady()

Sets up the component as soon as the media is playable.

Listens
media/ready
Source
PlaybackRate.js, line 102

private #toggleSpeed(value)

Changes playback speed.

Parameters:
Name Type Description
value number

The desired speed (1 is normal speed).

Source
PlaybackRate.js, line 119

private #onRateChange()

This handler is called if playback speed is changed (either by this component or otherwise). Updates the menus' "is-active" state accordingly.

Listens
media/ratechange
Source
PlaybackRate.js, line 131

private #enable()

Enables the menu functionality. This method listens to canplay events in order to restore a usable state again when the player recovered from a media error (for example by loading another file).

Listens
media/canplay
Source
PlaybackRate.js, line 146

private #disable()

Disables the menu functionality. This method listens to media error events which cause the button to be disabled.

Listens
media/error
data/nomedia
Source
PlaybackRate.js, line 157

destroy()

This method removes all events, subscriptions and DOM nodes created by this component.

Source
PlaybackRate.js, line 166