Skip to content

Module: src/controller/Play

The Play component shows a button which is used to start and pause playing the media. Also listens to the appropriate events should the media be paused or played by other means, and adapts the play button state accordingly (i.e. Showing the 'play' or 'pause' icon).

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

Constructor

new Play(player, parent)

Creates an instance of the Play component.

Parameters:
Name Type Description
player Player

Reference to the VisionPlayer instance.

parent Controller

Reference to the parent instance, in this case the controller component.

Members

Reference to the main player instance.

Type
Player
Source
Play.js, line 19

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

Type
Array<number>
Source
Play.js, line 25

Reference to the DomSmith instance of the play button.

Type
DomSmith
Source
Play.js, line 31

Methods

private #onDataReady()

Sets up the component as soon as the media data is available.

Listens
data/ready
Source
Play.js, line 73

private #togglePlay()

Invoked when the user presses the play button. Toggles between 'play' and 'pause'.

Source
Play.js, line 85

private #onPlay()

This method switches the appearance of the play button to the play state.

Listens
media/play
Source
Play.js, line 98

private #onPause()

This method switches the appearance of the play button to the pause state.

Listens
media/pause
Source
Play.js, line 111

private #disable()

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

Listens
media/error
data/nomedia
Source
Play.js, line 125

private #enable()

Enables the play button 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
Play.js, line 136

destroy()

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

Source
Play.js, line 145