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
|
Methods
adjustVideoHeight()
Adjusts the video height to maintain the correct aspect ratio based on the width of the video element.
destroy()
Destroys the video player instance by removing event listeners and cleaning up resources.
(async) handleVideoEnd()
Handles the video end event, either advancing to the next video or generating flow buttons if the video is looped.
(async) initialize()
Initializes the video player by preparing video files, setting up event listeners,
and displaying the initial loading screen and play button.
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. |
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.
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. |
(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. |
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.
(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. |