Constructor
new AnalyserVideo(player, config, apiKey)
Creates an instance of the AnalyserVideo component.
| Name | Type | Description |
|---|---|---|
player |
Player |
Reference to the VisionPlayer instance. |
config |
Object |
Configuration object for the AnalyserAudio component. This is passed from the subclass. |
apiKey |
symbol |
Token for extended access to the player API. |
Members
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
gridSize
|
number | optional | 3 | The number of grid cells per row/column. |
gridScale
|
number | optional | 3 | The scaling factor applied to the grid cells. |
lerp
|
number | optional | 0.6 | The interpolation factor used for smoothing pixel values. |
dim
|
number | optional | 1 | The dimming multiplier applied to pixel values. |
debug
|
boolean | optional | false | Enables debug mode with visual outputs. |
analyseTimer
|
number | optional | 250 | Delay (in ms) between iterations of the analysis loop. |
- Type
- Object
- Source
- AnalyserVideo.js, line 32
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- AnalyserVideo.js, line 38
private #subscriptions :Array<number>
Holds tokens of subscriptions (for this subclass only).
- Type
- Array<number>
- Source
- AnalyserVideo.js, line 44
private #apiKey :symbol
Secret key only known to the player instance and initialized components. Used to be able to restrict access to API methods in conjunction with secure mode.
- Type
- symbol
- Source
- AnalyserVideo.js, line 51
private #enabled :boolean
Flag indicating whether the analyser is enabled.
- Type
- boolean
- Source
- AnalyserVideo.js, line 57
private #canvas :HTMLCanvasElement|OffscreenCanvas
Canvas element for processing video frames.
- Type
- HTMLCanvasElement | OffscreenCanvas
- Source
- AnalyserVideo.js, line 63
private #ctx :CanvasRenderingContext2D
2D Rendering Context of the canvas.
- Type
- CanvasRenderingContext2D
- Source
- AnalyserVideo.js, line 69
private #debug :DomSmith
Debugging DOM elements created by DomSmith.
- Type
- DomSmith
- Source
- AnalyserVideo.js, line 75
private #debugInput :HTMLCanvasElement
Canvas element for input debugging.
- Type
- HTMLCanvasElement
- Source
- AnalyserVideo.js, line 81
private #debugInputCtx :CanvasRenderingContext2D
2D Rendering Context for the input debugging canvas.
- Type
- CanvasRenderingContext2D
- Source
- AnalyserVideo.js, line 87
private #debugOutput :HTMLCanvasElement
Canvas element for output debugging.
- Type
- HTMLCanvasElement
- Source
- AnalyserVideo.js, line 93
private #debugOutputCtx :CanvasRenderingContext2D
2D Rendering Context for the output debugging canvas.
- Type
- CanvasRenderingContext2D
- Source
- AnalyserVideo.js, line 99
private #pixelData :ImageData|null
Current pixel data after processing.
- Type
- ImageData | null
- Source
- AnalyserVideo.js, line 105
private #oldPixelData :Uint8ClampedArray
Previous pixel data for comparison and smoothing.
- Type
- Uint8ClampedArray
- Source
- AnalyserVideo.js, line 111
private #analyseLoop :Looper
Analyse Loop Instance, used for updating the viedeo data.
- Type
- Looper
- Source
- AnalyserVideo.js, line 117
private #refreshDelayId :number|undefined
Id for the refresh delay.
- Type
- number | undefined
- Source
- AnalyserVideo.js, line 123
Methods
private #onDataReady(mediaItem)
Handles "data/ready" events to activate video analysis based on media type. Deactivated when media type is audio.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
mediaItem |
Data~mediaItem |
Object containing media type info.
|
- Listens
- data/ready
- Source
- AnalyserVideo.js, line 184
startLoop()
Starts the analysis loop by initiating the first iteration.
- Listens
- media/play
- Source
- AnalyserVideo.js, line 217
stopLoop()
Stops the ongoing analysis loop.
- Listens
- media/pause
- Source
- AnalyserVideo.js, line 227
analyseLoop() → ImageData
Performs one iteration of the analysis loop.
- Returns
-
Calculated Image Data.
- Type ImageData
- Source
- AnalyserVideo.js, line 237
private #getPixelData(lerpValopt) → boolean
Retrieves and processes pixel data from the video stream. Draws a thumbnail for pixel analysis, divides it into grid cells, averages color values, and applies linear interpolation for smoothing.
| Name | Type | Attributes | Description |
|---|---|---|---|
lerpVal |
number | optional |
The interpolation value for smoothing. |
- Returns
-
True if pixel data was successfully retrieved and processed, false otherwise.
- Type boolean
- Source
- AnalyserVideo.js, line 258
private #refreshBounce()
Refreshes the analysis loop after a short delay.
- Source
- AnalyserVideo.js, line 318
refresh() → ImageData
Refreshes the pixel data immediately, resetting the interpolation.
- Listens
- media/seeked
- media/canplay
- Returns
-
Calculated Image Data.
- Type ImageData
- Source
- AnalyserVideo.js, line 331
enable()
Enables the analyser and restarts the analysis loop if playback is ongoing.
- Source
- AnalyserVideo.js, line 346
disable()
Disables the analyser.
- Source
- AnalyserVideo.js, line 357
destroy()
Removes all events, subscriptions and DOM nodes created by this component.
- Source
- AnalyserVideo.js, line 367