Play videos
Every video has a watch page and a player to embed, as soon as one of its formats is encoded: there's nothing to publish. For a player of your own, its HLS and DASH playlists are there too.
What plays is the same everywhere: who may watch (its playback_policy), the sites it may
be embedded on, and the player it plays in are the video's, set through the API or its
page in the dashboard. A signed or password video needs a token on each of these
links; see Access and permissions.
When it plays
A video plays once one format is ready: a video.ready webhook says so.
Until then Get Video's formats have no playable one, and the
watch page says it's still processing.
The watch page
https://your-crumbcast/watch/<video id>
A page of its own, with the video's title and description, to send as a link. Shared in a chat app or a CMS, it unfolds into the player (oEmbed, below).
Embedding the player
Put the embed page in an <iframe>. This one fills its container's width at the video's
shape:
<div style="position:relative;width:100%;aspect-ratio:16 / 9">
<iframe src="https://your-crumbcast/embed/<video id>" title="Launch day"
style="position:absolute;inset:0;width:100%;height:100%;border:0"
allow="autoplay; fullscreen; picture-in-picture; encrypted-media" allowfullscreen></iframe>
</div>
Or let a script tag put the same frame where it is:
<script async src="https://your-crumbcast/embed/script.js"
data-video="<video id>"
data-ratio="16 / 9"
data-title="Launch day"
></script>
The script tag's own attributes are data-video, data-title, data-ratio (16 / 9
unless you say) and data-vertical="1", which keeps a vertical video's player at most 360
pixels wide. The embed page takes these, as query parameters (or as data- attributes of
the script tag):
| Parameter | |
|---|---|
autoplay=1 | Starts at once, muted: browsers only autoplay muted videos |
muted=1 | Starts muted |
loop=1 | Plays again from the start when it ends |
controls=0 | The video alone, no control bar: for a page that controls it (below) |
start=<seconds> | Starts this far in |
player=<player id> | Plays in another of the project's players |
token=<token> | A signed or password video's playback token |
The video's embed_domains say which sites may embed it: host names, *.example.com
for its subdomains, or none for any site.
curl -X PATCH https://your-crumbcast/api/v1/videos/$VIDEO_ID/ \
-H "Authorization: Bearer $CRUMBCAST_TOKEN" \
-H "Content-Type: application/json" \
-d '{"embed_domains": ["example.com", "*.example.com"]}'
A player that stays blank or is refused is usually a Content Security Policy, the video's or your site's: see Troubleshooting.
Controlling it from your page
The embedded player talks with the page it's on through postMessage. Send it
{ type: "biscuit", method, value }:
method | value |
|---|---|
play, pause | |
seek | Seconds |
setMuted | true or false |
getState | It answers with a state event |
It sends { type: "biscuit", event, videoId, state } back, for ready, play, pause,
ended, timeupdate, volumechange and state. state is { currentTime, duration, paused, ended, muted }.
const frame = document.querySelector("iframe");
const player = (method, value) =>
frame.contentWindow.postMessage({ type: "biscuit", method, value }, "https://your-crumbcast");
window.addEventListener("message", (message) => {
if (message.origin !== "https://your-crumbcast" || message.data?.type !== "biscuit") return;
if (message.data.event === "ended") showNextVideo();
});
player("seek", 90);
player("play");
oEmbed
Get oEmbed turns a watch or embed link into the player's HTML, for CMSs and apps that read oEmbed:
curl "https://your-crumbcast/api/v1/oembed/?url=https://your-crumbcast/watch/<video id>&maxwidth=800"
Players
How the player looks is one of the project's players: its colours, corners, which
controls show, the quality it starts at, whether captions are on, your logo over the
video and where it links, and what happens at the end (play again, loop, or an end screen
with buttons). One of them is the project's default; a video plays in it unless it picks
another, or "platform" for the plain player:
curl -X PATCH https://your-crumbcast/api/v1/videos/$VIDEO_ID/ \
-H "Authorization: Bearer $CRUMBCAST_TOKEN" \
-H "Content-Type: application/json" \
-d '{"player": "<player id>"}'
Players are made in the project's Settings → Players, or with
Create Player and an admin token.
In a player of your own
Every video's files are under the API, for any HLS or DASH player (hls.js, Shaka Player, AVPlayer, ExoPlayer):
| HLS | /api/v1/videos/<id>/master.m3u8 |
| DASH | /api/v1/videos/<id>/manifest.mpd |
| Thumbnail | /api/v1/videos/<id>/thumbnail.jpg |
| Storyboard (timeline previews) | /api/v1/videos/<id>/storyboard.vtt |
| Chapters | /api/v1/videos/<id>/chapters.vtt |
| Captions | /api/v1/videos/<id>/captions/<caption id>.vtt, also in the HLS playlist |
The HLS playlist has every format of the video that's ready (H.264, H.265, AV1), so each
device picks what it plays. An AES-128 encrypted video plays over HLS only: it has no DASH
manifest. Add ?token= for a signed or password video: the playlist
passes it on to everything it lists.
Get Video Playback is what Crumbcast's own player reads:
the video's title, chapters, whether it plays yet (availability), and how its player
looks.
These answer pages on any site, so a player on yours can load them from the browser. The video's segments come from its storage: a storage of your own needs to allow your site too (its CORS settings).
A player of your own is in the analytics once it reports what it plays: see Players of your own.
Several videos one after the other, from one link: a playlist.