The J1 Template offers a collection of plugins to enhance VJS players, including features such as additional buttons and advanced keyboard support that allows for player control via predefined keys (hotkeys).
VideoJS Plugins
VideoJS provides a flexible and customizable platform for displaying and Controlling MPEG-4 video content on websites and web applications.
Plugin settings
Find below an excerpt of available configuration values for VideJS players.
Check the YAML configuration at _data\modules\defaults\gallery.yml
for all
configuration settings.
# --------------------------------------------------------------------------
# VideoJS options
#
videojsOptions:
enabled: false
controlBar:
playbackRates: [0.25, 0.5, 1, 1.5, 2]
remainingTimeDisplay: true
pictureInPictureToggle: false
volumePanel:
inline: false
hotkeysPlugin:
enabled: true
options:
volumeStep: 0.2
skipButtonsPlugin:
enabled: true
options:
forward: 15
backward: 15
zoomPlugin:
enabled: true
options:
moveX: 0
moveY: 0
rotate: 0
zoom: 1
Available Plugins
A set of handy plugins is available for VideoJS players to improve the user’s experience of playing video on a webpage. Note that plugins cannot used for all video sources. For example, the Zoom plugin is only available for MP4 video but is not compatible with online video sources provided by YouTube for example.
A plugin triggers the functionality of the underlying Video technology, respectively, the Provider API, to control and play a video of a specific type. Most online video providers do not support any zooming for videos, which results in the Zoom plugin not being available for online video sources. |
autoCaption
The autoCaption
plugin automatically enables the caption or subtitle track
to match the player’s language best. The plugin name needs to be revised, as
it has no relation to automatically generating captions. Language codes
are considered case-insensitive. If one or more tracks have a kind
of
captions
or subtitles
with an exactly matching language code, the first
will be selected.
If there is no exact match, the first captions
or subtitles
track where
the first part of the language code matches is selected, so en-US
would
match en
or en-gb
. If there is no match based on language, the first
captions
or subtitles
track with default
= true
will be selected.
The player language itself is either explicitly set as an option or is
derived from the closest element with a lang
attribute.
See //docs.videojs.com/player#language[VideoJS Docs, window="_blank"]
for more details.
hotKeys
The hotkeys
plugin for Video.js enables keyboard hotkeys when the
player has focus.
Key | Description |
---|---|
|
Toggles play and pause |
|
Toggles mute and unmute |
|
Toggles fullscreen off and on |
|
Seek the video back and forth the seekstep configured |
|
Increase and decrease the volume |
|
Keys from 1-9 seek the video to a percentage of:
|
Clicking any of the control buttons, such as Play/Pause, Fullscreen, or Mute, will remove focus from the player, which appears to break the hotkeys. For accessibility reasons, people who do not use or are unfamiliar with the
hotkeys can still properly use the |
To restore focus, click on the video or an empty part of the control bar
at the bottom of the video player. To override this behavior, set the
flag alwaysCaptureHotkeys
to true.
This setting will fix hotkeys.
For accessibility, the Tab
key may be used in combination with the
Enter
|Return
key to navigate and activate control buttons.
Options
The plugin hotKeys supports a set of customizable settings for more individual control over the plugin’s behavior.
Option | Type|Default | Description |
---|---|---|
|
decimal| |
The percentage to increase or decrease the volume level when using the Up and Down Arrow keys. |
|
integer| |
The number of seconds to seek forward and backwards when using the
Right and Left Arrow keys, or a function that generates an integer given
the |
|
function |
The number of seconds to seek forward and backwards when using a function
that generates an integer given on the |
|
boolean| |
Enables the volume mute to be toggle by pressing the M key. |
|
boolean| |
Enables increasing or decreasing the volume by scrolling the mouse wheel over the volume button (in the control bar). |
|
boolean| |
Only changes volume when the mouse is hovering over the volume control
elements. This works in connection with |
|
boolean| |
Enables toggling the video fullscreen by pressing the F key. |
|
boolean| |
Enables seeking the video by pressing the number keys. |
|
boolean| |
Enables the use of |
|
boolean| |
Forces the capture of hotkeys, even when control elements are focused. |
|
boolean| |
This reassigns focus to the player when the control bar fades out after a user has clicked a button on thecontrol bar. |
|
boolean| |
This stops focusing the player on initial Play under unique autoplay situations. + More information with Issue #44 |
|
boolean| |
Capture document keydown events to also use hotkeys even if the player
does not have focus. If you enable this option, you must configure
|
|
function| |
Filter function to capture document hotkeys (if |
|
boolean| |
Enables seeking the video in a broadcast-style jog by pressing the Up and Down Arrow keys. |
The Enter|Return key may be used instead to activate the control
elements (default: This feature may break accessibility, and cause unexpected behavior. |
This isn’t a feature for everyone, and enabling JogStyle will disable the volume hotkeys. |
Template Defaults
To avoid repeating standard settings, a set of default values is set over the Template defaults.
Option | Default |
---|---|
|
false |
|
15 |
|
0.1 |
|
true |
|
false |
|
function () { return false } |
|
true |
|
true |
|
false |
|
true |
|
false |
|
true |
|
false |
skipButtons
The plugin skipbuttons
adds Seek Buttons to the control bar. These
buttons allow the user to skip forward or backward by a configured number
of seconds.
Options
The plugin skip buttons support a set of customizable settings for more individual control over the plugin’s behavior.
Option | Type|Default | Description |
---|---|---|
|
integer|10 |
If a number greater than 0, a seek forward button will be added which seeks that number of seconds. |
|
integer|10 |
If a number greater than 0, a seek back button will be added which seeks that number of seconds. |
|
integer\1 |
Controls the position for the forward button to be inserted in the VJS player control bar. |
|
integer\1 |
Controls the position for the backward button to be inserted in the VJS player control bar. |
Control button positions
forwardIndex
and backwardIndex
control the posiiton of the button in the
controlbar.
If both a backward and forward button are used, the forward button is inserted always first. |
The play button for the VJS standard control bar is at index 0
. With the
default index of 1
for both, the forward button is inserted after the
play button; then, the back button is inserted after the play button and
before the forward button.
Setting backwardIndex
to 0
and forwardIndex
to 1
results in the
buttons surrounding the play button by placing the backward button before
the play button and the forward button after.
For the J1 template, a shorthand parameter |
Template Defaults
To not repaet standard settings, a set of default values are set over Template defaults.
Option | Default |
---|---|
|
false |
|
false |
|
1 |
|
1 |
|
10 |
|
10 |
zoomButtons
The plugin zoomButtons
adds a (zoom) button to the player’s control bar.
By clicking the button, a menu opens to access all possible functions
supported (enabled), such as zoom, flip, rotate, etc.
Methods
The behavior of the Zoom plugin can be controlled at runtime by following methods.
zoom(value)
Zoom function.
-
value type:
Number
const zoomPlugin = video.zoomPlugin();
zoomPlugin.zoom(2);
rotate(value)
Rotate function.
-
value type:
Number
in degree
const zoomPlugin = video.zoomPlugin();
zoomPlugin.rotate(180);
move(x, y)
Move function.
-
x type:
Number
-
y type:
Number
const zoomPlugin = video.zoomPlugin();
zoomPlugin.move(0, 0);
toggle()
Open and close the zoom menu.
const zoomPlugin = video.zoomPlugin();
zoomPlugin.toggle();
flip(signal)
Flip video.
-
signal type:
String
of+
or-
for flip the video.
const zoomPlugin = video.zoomPlugin();
zoomPlugin.flip("-");
Options
Example:
const zoomPlugin = video.zoomPlugin({
showZoom: true,
showMove: true,
showRotate: true,
gestureHandler: false
});
-
showZoom
show/hide +- zoom buttons. defaulttrue
-
showMove
show/hide up, left, right, reset and down buttons. defaulttrue
-
showRotate
show/hide rotate and flip buttons. defaulttrue
-
gestureHandler
enable gesture zoom drag and drop, wheel. defaultfalse
Events
For more control over zooming a video, the following events are available.
listen(event, callback)
Listen events of the zoom plugin.
-
event
-
type:
String
-
options:
-
'change'
when click in buttons modal -
'click'
when modal is opened or closed -
callback
-
type:
Function
const zoomPlugin = video.zoomPlugin();
zoomPlugin.listen('click', () => {
console.log('click');
});