Skip to content

Module: src/controller/Loop

The Loop component provides a simple button that allows the user to toggle the media's loop state in the settings menu. It listens to the player's loop events and updates its visual state accordingly. If the media is a live stream, the component disables itself.

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

Constructor

new Loop(player, parent)

Creates an instance of the Loop component.

Parameters:
Name Type Description
player Player

Reference to the VisionPlayer instance.

parent Controller

The parent container to which the fullscreen button will be appended.

Members

Reference to the main player instance.

Type
Player
Source
Loop.js, line 18

Reference to the parent instance.

Type
Controller
Source
Loop.js, line 24

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

Type
Array<number>
Source
Loop.js, line 30

DomSmith Instance representing the toggle button.

Type
DomSmith
Source
Loop.js, line 36

Methods

private #onMediaReady()

Sets up the component as soon as the media is available. Disables display if media is a live stream.

Listens
media/ready
Source
Loop.js, line 84

private #onLoopChange()

Handler which updates the loop control when the media loop state changes.

Listens
media/loop
Source
Loop.js, line 95

private #toggleLoop()

Invoked when the user clicks on the checkbox, toggles loop state between 'on' and 'off'.

Source
Loop.js, line 104

private #enable()

Enables the loop 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
Loop.js, line 115

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
Loop.js, line 126

destroy()

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

Source
Loop.js, line 135