Constructor
new Volume(player, parent)
Creates an instance of the Volume component.
| Name | Type | Description |
|---|---|---|
player |
Player |
Reference to the VisionPlayer instance. |
parent |
Controller |
Reference to the parent instance, in this case the controller. |
Members
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
slider
|
boolean | optional | true | If enabled, a volume slider is shown. If disabled, only muting / unmuting would be possible. |
sliderAutoHide
|
boolean | optional | true | If enabled, the slider is automatically hidden on |
private #player :Player
private #subscriptions :Array<number>
Holds tokens of subscriptions to player events, for later unsubscribe.
private #dom :DomSmith
private #savedVolume :number
private #firstTap :boolean
Helper variable used for touch interaction. Since in this case there is no mouseover, the first tap enables the slider, and a second one mutes the media.
private #autoHideId :number|undefined
Methods
private #toggleMute(eventopt)
Toggle mute state on click/tap:
- On touch devices: First tap -> reveal the volume slider / Second tap -> actually mute/unmute
- On desktop: single click -> toggle mute immediately.
| Name | Type | Attributes | Description |
|---|---|---|---|
event |
PointerEvent | optional |
The PointerEvent that triggered this call. |
private #setVolume()
private #onVolumeUpdate()
Updates slider values and also adapts the icon display based on the current volume.
- Listens
- data/ready
- media/volumechange
- Source
- Volume.js, line 168
private #showSlider(eventopt) → boolean|undefined
Shows the volume slider (if autohide is enabled).
| Name | Type | Attributes | Description |
|---|---|---|---|
event |
PointerEvent | optional |
The PointerEvent that triggered this call. |
private #hideSlider(eventopt)
Hides the volume slider (if autohide is enabled).
| Name | Type | Attributes | Description |
|---|---|---|---|
event |
PointerEvent | optional |
The PointerEvent that triggered this call. |
private #disable()
Disables the volume component (e.g., no media, or an error).
- Listens
- data/nomedia
- media/error
- Source
- Volume.js, line 225
private #enable()
Enables the volume component (e.g., once media can play).
- Listens
- media/canplay
- Source
- Volume.js, line 237