shaka-video
Video element powered by Shaka Player for DASH, HLS, and progressive playback with DRM
Video element powered by Shaka Player. One element plays DASH, HLS, and progressive files, and it’s the media component to reach for when you need DRM.
Load a source
src takes a manifest URL. DASH, HLS, and progressive files all go through the same property, and Shaka picks the parser from the URL.
<ShakaVideo src="https://example.com/manifest.mpd" /><shaka-video src="https://example.com/manifest.mpd"></shaka-video>When the URL carries no extension to go on, name the type with source.type. That’s what makes an extensionless manifest playable.
<ShakaVideo source={{ src: 'https://example.com/manifest', type: 'application/dash+xml' }} />const video = document.querySelector('shaka-video');
video.source = { src: 'https://example.com/manifest', type: 'application/dash+xml' };Protected content
source.drm names your license servers, keyed by EME key system id. Name every system you hold a license server for: which one gets negotiated is the browser’s choice.
<ShakaVideo
source={{
src: 'https://example.com/manifest.mpd',
drm: {
'com.widevine.alpha': { licenseUrl: 'https://example.com/widevine' },
'com.apple.fps': {
licenseUrl: 'https://example.com/fairplay',
serverCertificateUrl: 'https://example.com/fairplay.cer',
},
},
}}
/>const video = document.querySelector('shaka-video');
video.source = {
src: 'https://example.com/manifest.mpd',
drm: {
'com.widevine.alpha': { licenseUrl: 'https://example.com/widevine' },
'com.apple.fps': {
licenseUrl: 'https://example.com/fairplay',
serverCertificateUrl: 'https://example.com/fairplay.cer',
},
},
};FairPlay needs a serverCertificateUrl unless its CDM is pre-provisioned; Widevine and PlayReady ignore it. source.drm takes the same shape as hls.js’s own drmSystems, so one object describes DRM for either engine.
For the parts of Shaka’s DRM configuration this doesn’t cover, configure Shaka directly. A drm.servers under source.engine.shaka replaces source.drm rather than merging with it.
Behavior
- Adaptation stays within renditions no larger than the element rendering them, through Shaka’s
abr.restrictToElementSize. Override it undersource.engine.shaka. preload="none"defers the load until playback is asked for;autoplayor aplay()counts as asking.preload="metadata"loads, then holds Shaka’s buffering goals down to a second untilpreloadrises toauto.streamTypeis detected from the manifest, so a player skin renders live and on-demand content correctly without being told which it is.- Changing
source.engine.shakareconfigures the running player in place instead of recreating it.
Examples
Basic Usage
import { ShakaVideo } from '@videojs/react/media/shaka-video';
export default function BasicUsage() {
return <ShakaVideo className="shaka-video" src="https://dash.akamaized.net/akamai/streamroot/050714/Spring_4Ktest.mpd" autoPlay muted playsInline loop />;
}
.shaka-video {
width: 100%;
aspect-ratio: 16 / 9;
}
<media-container class="media-container">
<shaka-video
src="https://dash.akamaized.net/akamai/streamroot/050714/Spring_4Ktest.mpd"
autoplay
muted
playsinline
loop
></shaka-video>
</media-container>
.media-container {
position: relative;
display: block;
width: 100%;
aspect-ratio: 16 / 9;
}
import '@videojs/html/media/container';
import '@videojs/html/media/shaka-video';
API Reference
Attributes
Forwards these standard media attributes to the internal <video>. See the MDN media element reference: autopictureinpictureautoplaycontrolscontrolslistcrossorigindisablepictureinpicturedisableremoteplaybackloadingloopmutedplaysinlineposterpreloadsrc
These Video.js-specific attributes configure media behavior:
| Attribute | Type | Default | Details |
|---|---|---|---|
stream-type | MediaStreamType | 'unknown' |
Properties
| Property | Type | Default | Details |
|---|---|---|---|
contentData | Target["contentData"] | undefined | — | |
| |||
engine | Player | null | — | |
| |||
error | ErrorLike | null | — | |
| |||
isFullscreen | boolean | — | |
| |||
isPictureInPicture | boolean | — | |
| |||
liveEdgeStart | number | — | |
| |||
preload | MediaPreloadType | 'metadata' | |
| |||
source | ShakaSource | null | null | |
| |||
src | string | '' | |
streamType | MediaStreamType | 'unknown' | |
targetLiveWindow | number | — | |
| |||
webkitCurrentPlaybackTargetIsWireless | boolean | undefined | — | |
| |||
webkitPresentationMode | WebKitPresentationMode | undefined | — | |
| |||
webkitSetPresentationMode | ((mode: WebKitPresentationMode) => void) | undefined | — | |
| |||
Also exposes these properties from the native media API. See HTMLVideoElement for details: autoplaybufferedcontrolscrossOrigincurrentSrccurrentTimedefaultMuteddefaultPlaybackRatedisablePictureInPicturedisableRemotePlaybackdurationendedloopmutedpausedplaybackRateplayedplaysInlineposterreadyStateremoteseekableseekingtextTrackstitlevideoHeightvideoWidthvolume
Engine options
source.engine.shaka
Pass Shaka Player’s own configuration here. It’s handed to Shaka untouched, so every option in its configuration reference works, spelled the way Shaka spells it. Replacing the object resets any configuration applied before it. Media Sources covers how engine options fit into a structured source.
Each entry below is a group of Shaka settings rather than a single value, and Shaka documents what’s inside them. The names and types come from Shaka’s own type definitions.
<ShakaVideo
source={{
src: 'https://example.com/manifest.mpd',
engine: { shaka: { streaming: { bufferingGoal: 30 } } },
}}
/>const video = document.querySelector('shaka-video');
video.source = {
src: 'https://example.com/manifest.mpd',
engine: { shaka: { streaming: { bufferingGoal: 30 } } },
};| Option | Type | Details |
|---|---|---|
abr | object | |
| ||
abrFactory | Factory | |
accessibility | object | |
| ||
adaptationSetCriteriaFactory | Factory | |
ads | object | |
| ||
cmcd | object | |
| ||
cmsd | object | |
| ||
drm | object | |
| ||
ignoreHardwareResolution | boolean | |
lcevc | object | |
| ||
manifest | object | |
| ||
mediaSource | function | |
| ||
networking | object | |
| ||
offline | function | |
| ||
playRangeEnd | number | |
playRangeStart | number | |
preferredAudio | AudioPreference[] | |
preferredDecodingAttributes | string[] | |
preferredText | TextPreference[] | |
preferredVideo | VideoPreference[] | |
queue | object | |
| ||
restrictions | object | |
| ||
streaming | object | |
| ||
textDisplayer | object | |
| ||
textDisplayFactory | Factory | |
Methods
Supports these media methods. See HTMLVideoElement for details: addTextTrackcanPlayTypeexitFullscreenexitPictureInPictureloadpauseplayrequestFullscreenrequestPictureInPicture
Events
Re-dispatches these standard media events from the internal media element: abortaddtrackcanplaycanplaythroughchangecontentdatachangedurationchangeemptiedendedenterpictureinpictureleavepictureinpictureloadeddataloadedmetadataloadstartpauseplayplayingprogressratechangeremovetrackresizeseekedseekingstalledsuspendtimeupdatevolumechangewaiting
Also emits these Video.js-specific events:
| Event | Description |
|---|---|
error | Fired when playback fails in a way Shaka could not recover from. Read `error` for the failure. |
sourcechange | Fired when `source` changes, either directly or by resolving a new `src`. Read `source` for the new value. |
streamtypechange | Fired when the detected stream type changes. Read `streamType` for the new value. |
targetlivewindowchange | Fired when the live window duration changes. Read `targetLiveWindow` for the new value. |
CSS custom properties
| Variable | Details |
|---|---|
--media-video-border-radius | |
| |
--media-object-fit | |
| |
--media-object-position | |
| |
--media-caption-track-duration | |
| |
--media-caption-track-delay | |
| |
--media-caption-track-y | |
| |