Class: VideoPlayer

VideoPlayer(wrapper, config)

A class responsible for handling the video player functionality, including playing videos, rendering on the canvas, managing flow button generation, and handling video preparation based on internet speed.

Constructor

new VideoPlayer(wrapper, config)

Initializes the video player with the necessary configuration, video wrapper, and DOM elements.
Parameters:
Name Type Description
wrapper HTMLElement The DOM element where the video player will be attached.
config Object Configuration object containing video data and settings.
Properties
Name Type Description
VIDEO Array A collection of video data (URLs, posters, etc.).
testSpeedLink string A URL for testing internet speed to determine video quality.
startFlow string The initial flow to start playing (e.g., 'INTRO').
Source:

Methods

adjustVideoHeight()

Adjusts the video height to maintain the correct aspect ratio based on the width of the video element.
Source:

destroy()

Destroys the video player instance by removing event listeners and cleaning up resources.
Source:

(async) handleVideoEnd()

Handles the video end event, either advancing to the next video or generating flow buttons if the video is looped.
Source:

(async) initialize()

Initializes the video player by preparing video files, setting up event listeners, and displaying the initial loading screen and play button.
Source:

isLoopedVideo(index) → {boolean}

Checks if the video at the specified index is a looped video.
Parameters:
Name Type Description
index number The index of the video to check.
Source:
Returns:
True if the video is looped, false otherwise.
Type
boolean

loadAndPlayVideo()

Loads and plays the next video while adjusting the canvas and video element sizes.
Source:

playVideo(index)

Plays the video at the specified index in the videoFiles array.
Parameters:
Name Type Description
index number The index of the video to play.
Source:

(async) prepareFiles(scene) → {Promise.<Array.<Object>>}

Prepares the video files for the given scene, selecting the video quality based on internet speed. If internet speed is available, it tests the speed and chooses the appropriate video quality.
Parameters:
Name Type Description
scene string The name of the scene to load video files for.
Source:
Returns:
A promise that resolves to an array of video objects with the selected quality.
Type
Promise.<Array.<Object>>

renderVideoOnCanvas()

Renders the current video frame on the canvas at 60 FPS.
Source:

(async) runFlow(name)

Runs a video flow by preparing video files and appending them to the current video list.
Parameters:
Name Type Description
name string The name of the flow to run.
Source: