cloudflare-video
Video component that plays Cloudflare Stream videos through the Stream player
Video component that plays Cloudflare Stream videos through the Stream player embed. Cloudflare’s own chrome stays hidden by default, so it drops into a player skin like any other media component; set controls to use Cloudflare’s UI instead.
Load a source
src takes a raw 32-character video UID, any cloudflarestream.com or videodelivery.net URL, or a signed token. Watch, embed, iframe, manifest, and thumbnail URLs all carry the UID in the same position, and a signed token stands in for the UID wherever one appears.
<CloudflareVideo src="https://watch.videodelivery.net/bfbd585059e33391d67b0f1d15fe6ea4" /><cloudflare-video src="https://watch.videodelivery.net/bfbd585059e33391d67b0f1d15fe6ea4"></cloudflare-video>Signed playback
For signed URLs, pass the signed token wherever the UID would go: as the whole src, or inside a Stream URL. Keep your customer subdomain when your URLs name one. Cloudflare serves signed and access-controlled videos only from customer-<code>.cloudflarestream.com, so the element preserves that origin instead of collapsing it onto the shared host.
Behavior
A few things work differently from a native <video> element, because the Stream embed doesn’t expose them:
- The embed owns text tracks:
textTracksstays empty, andengine.cloudflare.defaultTextTrackpicks the track to show. - Picture-in-picture is unavailable, and the player reports it as unsupported.
- Fullscreen targets the iframe, so Cloudflare’s own chrome shows in fullscreen.
playsInlinehas no effect: the Stream embed always plays inline.
Examples
Basic Usage
import { CloudflareVideo } from '@videojs/react/media/cloudflare-video';
export default function BasicUsage() {
return (
<div className="cloudflare-video">
<CloudflareVideo src="https://watch.videodelivery.net/bfbd585059e33391d67b0f1d15fe6ea4" controls />
</div>
);
}
.cloudflare-video {
width: 100%;
aspect-ratio: 16 / 9;
}
<cloudflare-video
class="cloudflare-video"
src="https://watch.videodelivery.net/bfbd585059e33391d67b0f1d15fe6ea4"
controls
></cloudflare-video>
.cloudflare-video {
width: 100%;
aspect-ratio: 16 / 9;
}
import '@videojs/html/media/cloudflare-video';
API Reference
Attributes
These attributes configure the embedded media adapter:
| Attribute | Type | Default | Details |
|---|---|---|---|
autoplay | boolean | — | |
controls | boolean | — | |
loop | boolean | — | |
muted | boolean | — | |
playsinline | boolean | — | |
poster | string | — | |
preload | MediaPreloadType | — | |
src | string | — |
Properties
| Property | Type | Default | Details |
|---|---|---|---|
autoplay | boolean | — | |
buffered | TimeRangeLike | — | |
| |||
controls | boolean | — | |
currentSrc | string | — | |
| |||
currentTime | number | — | |
defaultMuted | boolean | — | |
duration | number | — | |
| |||
ended | boolean | — | |
| |||
engine | CloudflareStreamPlayerApi | null | — | |
| |||
error | MediaError | null | — | |
| |||
isFullscreen | boolean | — | |
| |||
loop | boolean | — | |
muted | boolean | — | |
paused | boolean | — | |
| |||
playbackRate | number | — | |
playsInline | boolean | — | |
poster | string | — | |
preload | MediaPreloadType | — | |
readyState | number | — | |
| |||
seekable | TimeRangeLike | — | |
| |||
seeking | boolean | — | |
| |||
source | CloudflareSource | null | — | |
| |||
src | string | — | |
textTracks | TextTrackListLike | — | |
| |||
videoHeight | number | — | |
| |||
videoWidth | number | — | |
| |||
volume | number | — | |
Engine options
source.engine.cloudflare
Pass Stream player parameters under source.engine.cloudflare, spelled exactly as Cloudflare spells them, plus anything Cloudflare adds next. They’re serialized onto the embed URL untouched, and the embed reads them once, when its URL is built. Media Sources covers how engine options fit into a structured source.
controls, autoplay, loop, muted, preload, and poster come from the props of the same name, so they have no engine.cloudflare spelling.
<CloudflareVideo
source={{
src: 'bfbd585059e33391d67b0f1d15fe6ea4',
engine: { cloudflare: { primaryColor: '#f03e3e', startTime: '5m30s' } },
}}
/>const video = document.querySelector('cloudflare-video');
video.source = {
src: 'bfbd585059e33391d67b0f1d15fe6ea4',
engine: { cloudflare: { primaryColor: '#f03e3e', startTime: '5m30s' } },
};| Option | Type | Details |
|---|---|---|
ad-url | string | |
| ||
defaultTextTrack | string | |
| ||
letterboxColor | string | |
| ||
primaryColor | string | |
| ||
referrerPolicy | ReferrerPolicy | |
| ||
startTime | string | number | |
| ||
Methods
Supports these media methods: exitFullscreenloadpauseplayrequestFullscreen
Events
Implements these standard media events through the embedded player: durationchangeemptiederrorloadedmetadataloadstartvolumechange
Also emits these Video.js-specific events:
| Event | Description |
|---|---|
loadcomplete | |
sourcechange | Fired when `source` changes, either directly or by resolving a new `src`. Read `source` for the new value. |