API REFERENCE · MEDIA
<dj-video>
A themed video player built on video.js.
video.js (version 8, which includes HLS support) plays the video and draws its own control bar. The component handles setup, theming, and events.
npm install @dojo-ng/video
import "@dojo-ng/video";
Before you use it
Load two things at the document level, because the component does not bundle them:
- The video.js stylesheet, with a
<link>in the page head. - video.js itself, resolved by your bundler or an import map.
Changing properties
src,sources, andposterupdate the playing video.muted,autoplay,loop,tracks, andlabelrecreate the player.
Events and methods
dj-play,dj-pause, anddj-endedfollow playback.dj-timereports{ current, duration }at most once per second.- Use these events for analytics, xAPI statements, or saving the playback position.
play()andpause()control playback.player()returns the video.js instance itself, for advanced use; the component does not support what you do with it.
Light DOM
- The player renders in the light DOM, because video.js adds its own DOM and styles, and its fullscreen and track menus do not work well inside a shadow root.
Not built
- Custom video controls. The video.js control bar is used as it is.
Need one of these? Make a request on Discord or add an issue (work item) on Heptapod.
Properties
| Property | Attribute | Type | Default |
|---|---|---|---|
sourcesOrdered source list ({ src, type }). Takes precedence over src. |
Property only | VideoJsSource[] |
None |
srcConvenience single source; becomes one entry in sources. |
src |
string |
None |
posterPoster image URL, shown before playback. |
poster |
string |
None |
mutedStart muted. |
muted |
boolean |
false |
autoplayStart playing (browsers require muted for autoplay). |
autoplay |
boolean |
false |
loopLoop playback. |
loop |
boolean |
false |
tracksText-track descriptors passed straight to video.js. |
Property only | unknown[] |
None |
labelAccessible name for the player. |
label |
string |
None |
Events
dj-playdj-pausedj-endeddj-time
Methods
| Method | Description |
|---|---|
play() | Start playback. |
pause() | Pause playback. |
player(): VideoJsPlayer | null | The underlying video.js player instance. Advanced escape hatch; no support implied. |