- Version
- 1.2.1
- License
- MIT
- Requires
- DomSmith
- convertTime
- Source
- Overlays.js, line 17
Constructor
new Overlays(player, parent, optionsopt)
Creates an instance of the Overlays component.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
player |
Player |
Reference to the VisionPlayer instance. |
|||||||||
parent |
Controller |
Reference to the parent instance. |
|||||||||
options |
Object | optional |
Additional options.
|
Members
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
adaptLayout
|
boolean | optional | true | Aligns overlay positioning with controller and title visibility state. |
sanitizeHTML
|
boolean | optional | false | Sanitizes the HTML of the overlay to prevent XSS attacks. |
- Type
- Object
- Source
- Overlays.js, line 25
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- Overlays.js, line 34
private #subscriptions :Array<number>
Holds tokens of subscriptions to player events, for later unsubscribe.
- Type
- Array<number>
- Source
- Overlays.js, line 40
private #dom :DomSmith
A DomSmith instance containing the overlay containers.
- Type
- DomSmith
- Source
- Overlays.js, line 46
private #overlays :Array<Overlays~overlayItem>
This array contains overlay data and elements.
- Type
- Array<Overlays~overlayItem>
- Source
- Overlays.js, line 52
Methods
private #onDataReady(mediaItem)
Called when the media data is ready. Extracts overlay definitions and sets them up.
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
mediaItem |
Data~mediaItem |
Object containing media type info.
|
- Listens
- data/ready
- Source
- Overlays.js, line 106
addOverlay(overlay)
Creates and adds a single overlay item to the DOM.
| Name | Type | Description |
|---|---|---|
overlay |
Data~mediaItem_overlay |
The overlay definition from the media data. |
- Source
- Overlays.js, line 128
private #onLoad(event)
Called when an overlay image loads successfully.
| Name | Type | Description |
|---|---|---|
event |
Event |
Original onload event. |
- Source
- Overlays.js, line 237
private #update(data, topic)
Updates the visibility of overlays based on the current playback time and status.
| Name | Type | Description |
|---|---|---|
data |
Object |
Event data (unused). |
topic |
string |
Event topic (checks for "ended" to handle "poster-end" posters). |
- Listens
- media/timeupdate
- media/seeked
- media/ended
- Source
- Overlays.js, line 262
private #enable()
Enables the next / prev 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
- Overlays.js, line 298
private #disable()
Disables the next / prev button functionality. This method listens to media error events which cause the button to be disabled.
- Listens
- media/error
- data/nomedia
- Source
- Overlays.js, line 309
private #removeOverlays()
Helper function which removes all overlays.
- Source
- Overlays.js, line 318
destroy()
This method removes all events, subscriptions and DOM nodes created by this component.
- Source
- Overlays.js, line 331
Type Definitions
overlayItem
Represents a single overlay item with its own DOM element and display rules.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
ele
|
HTMLElement | The DOM element containing the overlay. |
||
type
|
string | Overlay type (e.g. 'image', 'poster', 'poster-end'). |
||
src
|
string | Source URL of the overlay image (if applicable). |
||
show
|
string | optional | Controls when the overlay should be displayed, e.g. 'begin', 'end', 'pause', 'play'. |
|
className
|
string | optional | "" | Additional CSS classes to apply to the overlay element. |
scale
|
string | optional | Determines how to scale the overlay, e.g. 'cover" or 'contain'. If undefined, no scaling is applied. |
|
placement
|
string | optional | 'center' | Controls overlay placement, e.g. 'top', 'bottom-right', etc. |
margin
|
number | optional | 0 | Margin (in px) around the overlay content. |
cueIn
|
number | optional | 0 | Start time in seconds when this overlay should appear. |
cueOut
|
number | optional | Infinity | End time in seconds when this overlay should disappear. |
visible
|
boolean | Whether the overlay is currently visible or not. |
||
background
|
boolean | optional | True if the overlay uses a background image (for 'cover' / 'contain' scaling). |
|
opaque
|
boolean | optional | True if the overlay background is opaque (e.g. For a poster). |
|
loaded
|
boolean | optional | True if the overlay image has finished loading. |
|
img
|
HTMLImageElement | optional | The underlying |
- Type
- Object
- Source
- Overlays.js, line 342