<content-video>
A video player for YouTube or self hosted files, built on Video.js.
import '@content-blocks/js/components/content-video';Examples
A YouTube video
The player loads a YouTube video in a Video.js player with its own controls.
<content-video src="https://www.youtube.com/watch?v=eRsGyueVLvQ" controls="true"></content-video>// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-video';<script type="module"
src="https://cdn.jsdelivr.net/npm/@content-blocks/js/dist/content-blocks/content-blocks.esm.js"></script>Anatomy
Content goes into the component's slots, chosen with the slot attribute on each child.
flowchart LR root["#lt;content-video#gt;"]:::component root --> s0["<b>no slot (default)</b><br/>Default slot, same as content slot."] root --> s1["<b>slot=#quot;content#quot;</b><br/>Adjacent to no-js message for video. Usually not needed."] root --> s2["<b>slot=#quot;no-js-message#quot;</b><br/>Contents of no JS message."] root --> s3["<b>slot=#quot;playButton#quot;</b><br/>Play button contents."] root --> s4["<b>slot=#quot;poster#quot;</b><br/>Poster shown before video is played."] classDef component fill:#141413,color:#faf9f5,stroke:#141413
| Slot | What goes in it |
|---|---|
(default) | Default slot, same as content slot. |
slot="content" | Adjacent to no-js message for video. Usually not needed. |
slot="no-js-message" | Contents of no JS message. |
slot="playButton" | Play button contents. |
slot="poster" | Poster shown before video is played. |
Properties
Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.
| Attribute | Type | Default | Description |
|---|---|---|---|
autoplay | Boolean | false | If you're using this inside a content-overlay for example, you may want the video to play immediately on launch. |
autoplay-mute | Boolean | true | Sets whether or not an autoplaying video should be muted. By default autoplay videos will be muted. |
classesresponsive | String | – | Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side". |
controls | Boolean | true | Not documented yet |
fit-containerresponsive | String | 'false' | Fit the container this video is placed in. When the video is used in an overlay or another place where the video will takeover the existing height, it is recommended to enable this option. |
height | Number | 9 | Not documented yet |
method | Select | 'youtube' | Not documented yet |
paddingresponsive | String | – | Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem". |
play-button-aria-label | String | 'Play' | Not documented yet |
preload | String | 'metadata' | Not documented yet |
src | String | '' | Supports YouTube and self hosted URLs. |
type | String | 'video/mp4' | Not documented yet |
width | Number | 16 | Not documented yet |
Events and methods
sequenceDiagram participant Page participant C as content-video Page->>C: contentOverlayDeactivated event
