- Version
- 1.0.0
- License
- MIT
- Extends
- AnalyserAudio
- Requires
- VisualizerTimeWorker
- supportsWorkerModules
- DomSmith
- Source
- VisualizerTime.js, line 19
Constructor
new VisualizerTime(player, parent, optionsopt)
Creates an instance of the VisualizerTime component.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
player |
Player |
Reference to the VisionPlayer instance. |
|||||||||
parent |
AudioChain |
Reference to the parent instance. |
|||||||||
options |
Object | optional |
Additional options.
|
Members
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- VisualizerTime.js, line 25
private #subscriptions :Array<number>
Holds tokens of subscriptions (for this subclass only).
- Type
- Array<number>
- Source
- VisualizerTime.js, line 31
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
- VisualizerTime.js, line 38
private #dom :DomSmith
Reference to the DomSmith Instance.
- Type
- DomSmith
- Source
- VisualizerTime.js, line 44
private #canvas :Object
Local canvas element and 2D context for rendering when worker is not used.
| Name | Type | Description |
|---|---|---|
ele
|
HTMLCanvasElement | The canvas element. |
ctx
|
CanvasRenderingContext2D | The 2D rendering context. |
- Type
- Object
- Source
- VisualizerTime.js, line 52
private #worker :VisualizerTimeWorker
Optional worker which renders the canvas offscreen.
- Type
- VisualizerTimeWorker
- Source
- VisualizerTime.js, line 58
private #useWorker :OffscreenCanvas|undefined
Indicates if OffscreenCanvas worker rendering is used.
- Type
- OffscreenCanvas | undefined
- Source
- VisualizerTime.js, line 64
Methods
async, private #initWorker()
Initializes the worker for offloading rendering, if supported. If workers are not supported, sets up local canvas rendering.
- Source
- VisualizerTime.js, line 108
startLoop()
Starts the audio analysis loop.
- Listens
- media/play
- Source
- VisualizerTime.js, line 132
analyseLoop()
Overrides the parent's analyseLoop method to render time-domain data.
- Listens
- media/play
- media/pause
- Source
- VisualizerTime.js, line 145
private #render(timeData)
Renders the time-domain data as a waveform on the canvas.
| Name | Type | Description |
|---|---|---|
timeData |
Array<Array<number>> |
Array of time-domain data per channel. |
- Source
- VisualizerTime.js, line 158
private #resize()
Invoked when window resizes. Sets the canvas dimensions accordingly.
- Listens
- ui/resize
- Source
- VisualizerTime.js, line 191
destroy()
This method removes all events, subscriptions and DOM nodes created by this component.
- Source
- VisualizerTime.js, line 211