Streams (HLS and DASH)
Put MP4E interactivity on a video that is delivered as a stream — recorded or live — while your own streaming library, or the browser, plays it.
Overview
An MP4E file carries its interactivity inside the file. A stream has no such file: the video arrives in small pieces listed in a playlist, played by the browser (HLS in Safari) or by a library such as hls.js, Shaka Player or dash.js. MP4E does not play the stream for you. You keep the player stack you have; MP4E watches the same <video> element and draws overlays, plugins and controls over it.
Tell the player the video is a stream, and give it the interactivity yourself — as a document (metadata) or as overrides on an empty one.
| Prop | Type | Default | Description |
|---|---|---|---|
stream | boolean | false | The video is a stream (HLS or DASH), not one MP4 file. The player reads nothing from the video address; the document is your metadata when given, else an empty generated one. Implied by attachSource. Read when the player is created. |
attachSource | (video: HTMLVideoElement) => void | (() => void) | - | Feed the player's <video> with your own library. Called with the element before the player starts; return a function that detaches the library. On a live stream both may be called again (see Loops, pauses and jumps on live). The player then sets no src, preload or crossOrigin on the element. Read when the player is created. |
documentSrc | string | - | The exported MP4E file whose interactivity belongs to the stream. Its signed document, objects and in-file media are read from it in small byte ranges while the picture comes from the stream. Read when the player is created. |
src | string | - | With stream: the address of a stream the browser plays by itself (an HLS playlist in Safari). Leave it out when attachSource feeds the element. |
React
With a library, pass attachSource. The component still owns the element — it sizes it and stacks the overlays on it — and your function attaches the library to it.
import Hls from 'hls.js';
import { MP4EPlayer } from '@mp4e/react';
import '@mp4e/react/styles.css';
function Stream({ url }: { url: string }) {
return (
<MP4EPlayer
key={url}
attachSource={(video) => {
const hls = new Hls({ liveDurationInfinity: true });
hls.loadSource(url);
hls.attachMedia(video);
return () => hls.destroy();
}}
overrides={overrides}
/>
);
}attachSource is read once. To play another stream in the same place, change the component's key.
Where the browser plays the stream by itself, pass its address and stream:
// Safari and iPhone play HLS by themselves
<MP4EPlayer src="https://example.com/live/stream.m3u8" stream overrides={overrides} />Without React
The engine takes a <video> your page already owns. Attach your library first, then create the engine with stream: true.
import Hls from 'hls.js';
import { MP4Engine } from '@mp4e/player';
const video = document.querySelector('video');
const hls = new Hls({ liveDurationInfinity: true });
hls.loadSource(url);
hls.attachMedia(video);
const engine = new MP4Engine(
{ video, overlayContainer, canvas },
{ stream: true, controls: true },
);
await engine.init(); // or engine.init(yourDocument)
await engine.play();Which player feeds the video
- Safari and iPhone: the browser's own HLS playback.
- Chrome, Edge, Firefox, Android, and TVs built on Chromium: a library that plays through Media Source Extensions (hls.js, Shaka Player, dash.js).
// Safari's own HLS playback has a stream clock; Chrome's built-in one does not.
const probe = document.createElement('video');
const safariHls =
probe.canPlayType('application/vnd.apple.mpegurl') !== '' &&
typeof (probe as any).getStartDate === 'function';
return safariHls
? <MP4EPlayer src={url} stream />
: <MP4EPlayer key={url} attachSource={(video) => attachHls(video, url)} />;The interactive document
With no metadata, the player starts from an empty document sized to the video; add layers, plugins, variables and rules through overrides, and change them while the stream plays with updateOverrides().
To run a full authored document over a recorded stream, pass it as metadata. On a stream videoDetails.durationSeconds may be left out. Frame-based timing (visibility ranges, scenes) uses videoDetails.fps, 30 when the document is generated.
<MP4EPlayer
attachSource={attach}
metadata={{
schemaVersion: '2.0',
// No durationSeconds: a stream's length comes from the video itself
videoDetails: { width: 1920, height: 1080, fps: 25 },
layers: [ /* overlays */ ],
plugins: { /* ... */ },
variables: [],
}}
/>An MP4E file beside the stream
A video you made interactive in the Studio can be delivered as a stream and keep everything: export it, serve the exported file next to the stream, and name it with documentSrc. The picture comes from the stream. The player reads the signed document from the file, and then the tracked objects, mattes, clean plates, images and thumbnails as they are needed, in small byte ranges; the file is never downloaded whole. It must allow range requests from your page, as any MP4E file does.
// A recorded stream of a video you exported from the Studio
<MP4EPlayer
key={url}
attachSource={(video) => { /* hls.js, as above */ }}
documentSrc="https://cdn.example.com/show.mp4"
/>
// Live: each programme names its own file
<MP4EPlayer
key={url}
attachSource={(video) => { /* hls.js, as above */ }}
live={{
getLiveEdge: () => hls.liveSyncPosition,
clock: pictureDate(hls),
programme: { start: '2026-11-11T20:00:00Z', file: 'https://cdn.example.com/the-final.mp4' },
}}
/>
// The next programme, while playing
engine.setProgramme({ start: '2026-11-11T21:30:00Z', file: 'https://cdn.example.com/the-news.mp4' });- The stream must show the file's frames: the same frame rate, every frame kept, and nothing inserted before the programme's first frame.
- On a live stream a programme's
filedoes the same for that programme. While the file is being read, content with a frame range waits; the same file again (a repeat) starts at once. - A file that cannot be read or does not verify raises
programme:documentFailed({ file, reason }) and the picture plays on without interactivity. - Your
overridesapply to whichever document is loaded, and what they add keeps running when the document changes: your plugins are not reloaded and your variables keep their values, so a cart or a "now playing" strip lasts across programmes. The video's own variables start fresh with each document. - A scene that loops does not loop on a live stream: it ends like any other scene.
Live streams
Say the stream is live with live. The player then knows where the live edge is and how far behind it the viewer is, and the controls change to match:
- A LIVE mark: red while the viewer watches live, grey when they are behind. Pressing it returns to live.
- The progress bar spans what the stream lets the viewer replay, up to the live edge. Seeking — a drag, a click, the ten-second steps of a keyboard or a TV remote — stays inside it.
- Instead of a position, the time shows how far behind the viewer is (
-0:23), and nothing at the live edge. - A stream with nothing to replay gets no progress bar.
<MP4EPlayer
key={url}
attachSource={(video) => {
hls = new Hls({ liveDurationInfinity: true });
hls.loadSource(url);
hls.attachMedia(video);
return () => hls.destroy();
}}
live={{ getLiveEdge: () => hls.liveSyncPosition }}
overrides={overrides}
/>
// Safari and iPhone
<MP4EPlayer src={url} stream live overrides={overrides} />| Prop | Type | Default | Description |
|---|---|---|---|
live | boolean | LiveOptions | false | The stream is live. true, or the options below. Implies stream. Read when the player is created; false later is applied at once. |
live.dvr | boolean | true | The viewer may seek inside what the stream lets them replay. false: the viewer cannot seek, and unless you set live.shift nothing in the video moves them off live either. |
live.shift | 'auto' | 'file' | 'window' | 'off' | 'auto' | Where a viewer may watch once something in the video takes them off live (a pause, a scene's loop, a jump back). 'auto': inside what the stream lets them replay while it still holds that moment, and from the programme's file (live.programme.file) when it does not. 'file': always from the file. 'window': never from the file. 'off': nobody leaves live; every such action from the video or a plugin is skipped. Your own calls always work. |
live.onLive | 'shift' | 'skip' | 'shift' | For a video that does not say: what a loop, a pause or a jump does on live. shift: it runs and the viewer is time-shifted. skip: it does not, and the broadcast carries on. The video's own setting comes first. |
live.maxBehindSeconds | number | - | The furthest a viewer may fall behind live. Past it they are returned to live, and a jump further back than this is not made. |
live.rejoinAtProgrammeEnd | boolean | false | A viewer who is behind returns to live when their programme ends. |
live.sessions | boolean | true | Whether a session video may be played as a session on this stream. false: it airs as footage only and is never offered. |
live.resumeAtLiveEdge | boolean | false | Playing after a pause returns to live instead of continuing from where the viewer stopped. |
live.edgeTolerance | number | 5 | Seconds behind the live edge that still count as watching live. |
live.getLiveEdge | () => number | null | - | Where your player keeps live playback, in the video element's time (hls.js: () => hls.liveSyncPosition). Read once a second. Without it the end of the element's seekable range is the live edge. |
live.clock | () => Date | number | null | - | The broadcast clock: the real date and time of the picture now on screen (hls.js: see The clock from hls.js). Read once a second. Not needed in Safari, whose own player is read directly. |
live.programme | { start, end?, title?, file?, path?, resumes? } | - | The programme on air. start and end are a Date, epoch milliseconds or an ISO string. With it, time in the player counts from the programme's start. file: the exported MP4E file whose interactivity is this programme's. path: the file's ranges your stream airs, in order, as [{ from, to }] in seconds, when the stream does not air the whole file (see Loops, pauses and jumps on live). resumes: where the programme picks up after an ad break in the stream, as [{ at, position }]. |
live.duringBreak | 'hide' | 'keep' | 'hide' | During an ad break in the stream: hide every overlay until it ends, or keep them and decide with {{inAdBreak}} in your own rules. |
live.breakClasses | string[] | - | Classes of stream messages that are ad breaks, besides a SCTE-35 splice-out and the class break. |
live.streamCues | boolean | true | Read the messages the stream carries from the video element. false: you hand them over with engine.notifyStreamCue(). |
live.assumedDelaySeconds | number | - | When the stream carries no dates: estimate the broadcast clock as the device's clock minus this many seconds. Timed content then lands a few seconds off, differently for each viewer. |
After a pause the viewer continues from where they stopped and can press LIVE to catch up. Set resumeAtLiveEdge to return to live on every play instead.
Time on a live stream
On a live stream every viewer's video element counts time from wherever their own player began, so second 40 is a different picture for each of them. To time content to the picture, give the player two things: the broadcast clock (the real date and time of the picture on screen, which the stream carries) and the programme on air.
<MP4EPlayer
key={url}
attachSource={(video) => { /* hls.js, as above */ }}
live={{
getLiveEdge: () => hls.liveSyncPosition,
clock: pictureDate(hls),
programme: { start: '2026-11-11T20:00:00Z', end: '2026-11-11T21:30:00Z', title: 'The Final' },
}}
metadata={programmeDocument}
/>
// The next programme starts: no reload
engine.setProgramme({ start: '2026-11-11T21:30:00Z', title: 'The News' });With both, time in the player is programme time: second 0 and frame 0 are the programme's start, for every viewer, whatever their delay. A document made for the programme then works as it is:
- An overlay's
visibilityframes, scenes, and rules that read{{currentTime}}or{{currentFrame}}count from the programme's start. engine.seek(t)and a plugin's seek take programme time; the player moves the video element to the matching place.- The player's built-in controls show the position in the programme (
41:07, or41:07 / 1:30:00when the programme has an end). {{programmeTime}}is the position in seconds and{{broadcastTime}}the date of the picture on screen, in epoch milliseconds.- A viewer who joins late lands in the middle of the programme: what should be on screen at that moment shows, and nothing that came before fires.
The stream must carry dates for this: EXT-X-PROGRAM-DATE-TIME in an HLS playlist. In Safari the player reads them itself. With hls.js, pass clock. Until a clock is known, content with a frame range waits and content without one shows; the same holds before the programme's start. Nothing timed is guessed.
// hls.js dates the start of a segment. A stream encoded with B-frames shows the
// segment's first picture a couple of frames later, so subtract that lead.
function pictureDate(hls) {
let lead = null;
hls.on(Hls.Events.FRAG_CHANGED, (_e, { frag }) => {
const video = frag.elementaryStreams.video;
lead = video ? Math.max(0, video.startPTS - frag.start) : 0;
});
return () => (hls.playingDate && lead !== null ? hls.playingDate.getTime() - lead * 1000 : null);
}live:state says clockCoarse: true. A stream with no dates can still run on assumedDelaySeconds, a few seconds off; live:state then says clock: "estimated", and you can choose to show nothing timed in that case.A programme's start may be at most 24 hours back; an older one is refused with programme:refused. For a channel that never ends, set the start to the top of the hour or of the day and call engine.setProgramme() again when it turns. Without a programme nothing changes: time stays the video element's own.
Timed content: a live vote
The presenter says "vote now" and the vote must open on that picture for every viewer, although each of them is a different number of seconds behind. Give the overrides a time: the player applies them when the viewer's own picture reaches it on the broadcast clock.
// Keep the plugin and the variables in every entry; only the overlay comes and goes.
const base = { plugins: { 'acme:vote': votePlugin }, variables: [{ id: 'myVote', name: 'myVote', type: 'number', default: 0 }] };
const open = { ...base, layers: [{ id: 'host', name: 'Host', order: 1000, overlays: [voteOverlay] }] };
const closed = { ...base, layers: [{ id: 'host', name: 'Host', order: 1000, overlays: [] }] };
// One at a time, as your control room decides
engine.updateOverrides(open, { at: '2026-11-11T20:41:07Z' });
engine.updateOverrides(closed, { at: '2026-11-11T20:43:07Z' });
// Or the whole list — also what a viewer who joins late is given
engine.setOverrideSchedule([
{ at: '2026-11-11T20:41:07Z', overrides: open },
{ at: '2026-11-11T20:43:07Z', overrides: closed },
]);
// React
<MP4EPlayer src={url} stream live overrideSchedule={schedule} />- Each entry is a whole overrides object. The player applies the latest entry whose time has passed; before the first one, your plain
overridesapply. - A viewer who joins in the middle gets the entry of that moment at once. Send the current list when the page loads.
- A viewer who seeks back sees what was on screen then: the vote is closed again before its time.
atis aDate, epoch milliseconds or an ISO string. An entry given again for the same time replaces the earlier one. The list holds 64 entries; the earliest go first.overrides:appliedtells you when an entry took effect ({ at, now, clock }).
This needs the broadcast clock (see Time on a live stream); it does not need a programme. When the stream carries no dates, an entry applies when its time comes on the device's own clock, which is a few seconds before the delayed picture shows it. How the list reaches your page (a WebSocket, polling) and how votes are counted are yours: the player sends the viewer's choice to your page as a plugin event, and you send the count back with setVariable.
overrides:scheduleWarning when an entry drops one.Messages inside the stream
A broadcaster's control room can mark moments in the stream itself: an EXT-X-DATERANGE tag in an HLS playlist, an ID3 tag, a SCTE-35 splice. The player reads them from the video element, in Safari and with hls.js alike, and raises stream:cue when the viewer's own picture reaches the marker, so a rule can act on the frame the control room meant.
// In your document or overrides: a rule on the stream's own markers
rules: {
'stream:cue': [{
id: 'open_vote', name: 'Open the vote', enabled: true,
conditions: { logic: 'ALL', conditions: [
{ type: 'eventData', path: 'data.X-KIND', operator: 'eq', value: 'vote' },
] },
actions: [
{ type: 'setVariable', variableId: 'question', value: '{{eventData.data.X-QUESTION}}' },
{ type: 'showOverlay', overlayId: 'vote' },
],
}],
}
// In the stream (your packager writes this):
// #EXT-X-DATERANGE:ID="vote-17",START-DATE="2026-11-11T20:41:07Z",X-KIND="vote",X-QUESTION="Who wins?"- The event carries
{ id, class, data, start, startTime, end, endTime, duration, break, late }.dataholds the marker's fields; a rule reads them as{{eventData.data.…}}, and plugins get the event withmp4e.on('stream:cue'). - Browsers pass a DATERANGE's
X-attributes and its SCTE-35 fields, but not itsCLASS. Put what your rules need intoX-attributes. - A marker is raised once. A viewer who joins or seeks to a point after a moment does not get it; one who lands inside a marker that has a length gets it with
late: true. - This needs no broadcast clock: the markers are timed in the video element's own time.
// Listen in your page
engine.onEvent('stream:cue', ({ data }) => console.log(data.id, data.data));
engine.onEvent('live:break', ({ data }) => setInBreak(data.active));
// Or hand markers over yourself, when your player knows more than the browser exposes
hls.on(Hls.Events.LEVEL_UPDATED, (_e, { details }) => {
for (const id in details.dateRanges) {
const r = details.dateRanges[id];
engine.notifyStreamCue({ id, class: r.class, start: r.startDate, duration: r.duration, data: r.attr });
}
});Ad breaks in the stream
An ad stitched into a live stream is part of the picture; there is nothing for the player to play. What matters is that your overlays do not sit on another brand's ad. When a marker is an ad break, the player hides every overlay for its length and brings them back when it ends.
- A marker is a break when it carries a SCTE-35 splice-out (
SCTE35-OUT), when its class isbreak, or when its class is one you list inlive.breakClasses. live:breaktells your page when a break begins and ends, and{{inAdBreak}}is true during it.live.duringBreak: 'keep'hides nothing: your own rules decide with{{inAdBreak}}, for example to keep a channel logo and hide the rest.- A break with no length lasts until the marker comes again with one.
A break makes a programme longer on air than its own length, so tell the player where the programme picks up: resumes: [{ at, position }] on the programme says that at the date at the programme is at position seconds. Each viewer follows it when their own picture gets there, so a viewer who is behind, or who joins after the break, sees the right moment. Call engine.setProgramme() again with the list as breaks happen.
The stream's subtitles and audio
A stream brings its own subtitle and audio tracks. The player lists them in its settings menu: the subtitle tracks under Subtitles, and an Audio Track entry when the stream has more than one. The viewer's language is remembered and applied to the next stream that has it.
- Tracks the browser lists on the video element need nothing from you: subtitle and caption tracks everywhere (hls.js puts its subtitle renditions there too), audio tracks in Safari.
- For tracks only your player knows, report the list with
engine.setStreamTracks()and switch the track inonStreamTrack. engine.selectStreamTrack(kind, id)chooses a track yourself (nullturns subtitles off);engine.getStreamTracks()reads the lists;stream:tracksandstream:trackChangedtell your page when they change.
// hls.js knows its audio renditions; the video element does not
const report = () => engine.setStreamTracks({
audio: hls.audioTracks.map((t, i) => ({ id: String(i), label: t.name, language: t.lang, selected: i === hls.audioTrack })),
});
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, report);
hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, report);
<MP4EPlayer
attachSource={attach}
live
onStreamTrack={({ kind, id }) => { if (kind === 'audio' && id !== null) hls.audioTrack = Number(id); }}
/>Loops, pauses and jumps on live
On a file the viewer owns time: a scene can loop until they pick something, a rule can pause for an answer, a choice can jump back. On a live stream the broadcast owns time, so each of these would take the viewer off it. What happens then is programmed, by the video and by you.
The actions seek, seekRelative, goToScene and pause, and a scene's loop, each take an onLive setting:
"shift"— it runs. The viewer is now behind live, watching inside what the stream lets them replay, and stays there until they press LIVE or something sends them back."skip"— it does not run. The broadcast carries on, andaction:blockedsays so.
The first that says anything decides: the action's own onLive, then the video's settings.live.onLive, then your live.onLive, then shift. So a video made with no thought of live behaves as it does as a file, as far back as the stream lets a viewer go.
Your ceiling is over all of it. live.shift: 'off' keeps every viewer on live. live.maxBehindSeconds bounds how far behind anyone may fall. And because overrides follow the video's structure, you can set onLive on one scene of a video you did not make:
A programme that names its file (live.programme.file) holds every moment of itself, so a viewer is not limited to what the stream still has. When a loop or a jump needs a moment the stream no longer holds, the player plays the programme's file on the same video element, at that moment, and everything works as it does on a file. The LIVE mark, goLive() and your limit put the stream back. live:state says watching: "file" meanwhile, and a file that cannot be played raises live:shiftFailed and returns the viewer to live.
A stream is one picture, so of a programme that branches it carries one path. Say which with live.programme.path: the file's ranges your stream airs, in order. The player then knows what is on air at every moment. A viewer whose video sends them to footage that is not on air watches it from the file, and when their place in the file meets what is on air they are back on the stream. Two scenes of the same length, one per audience, cost such a viewer no time at all:
<MP4EPlayer
attachSource={attachSource}
live={{
getLiveEdge: () => hls.liveSyncPosition,
programme: {
start: '2026-11-12T20:00:00Z',
file: 'https://cdn.example.com/show.mp4',
// Common part 0:00–4:00, scene A 4:00–5:00, scene B 5:00–6:00, common part 6:00–10:00.
path: [{ from: 0, to: 300 }, { from: 360, to: 600 }],
},
}}
/>A viewer who jumps past what has aired is ahead of the broadcast: {{aheadOfLive}} says by how many seconds, and live:state carries ahead. When their programme ends and the next one has a file, it starts for them at once. When it has none, live:waiting tells you how long they wait for the broadcast, so you can show something of your own.
attachSource returned, and calls attachSource again when the viewer returns to live. Make both safe to repeat: create the library inside attachSource and destroy it in the function you return. With @mp4e/player, pass streamSource: { detach, attach } in the engine's config. A stream the browser plays by itself needs nothing.A viewer on the file sees none of the ad breaks stitched into your stream. Set live.shift: 'window' to keep everyone on the stream.
<MP4EPlayer
attachSource={attachSource}
live={{
getLiveEdge: () => hls.liveSyncPosition,
onLive: 'skip', // videos that say nothing stay on live
maxBehindSeconds: 60,
}}
overrides={{
sceneGroups: [{
id: 'group_main',
scenes: [{ id: 'scene_showroom', loop: { onLive: 'shift' } }],
}],
}}
/>shift, a scene that loops with no end keeps its viewer on each pass, further behind live every time. Give such a show onLive: "skip" on that loop, or set live.maxBehindSeconds.The viewer's own pause and seek on the controls are theirs: they carry no onLive, and only live.dvr: false or a stream with nothing to replay stops a seek. Your own calls are never refused.
A shared show with a personal part
Some videos are the same for everyone for a while, then personal: a host sells a ticket to the whole audience, each viewer plays their own and sees their own result. Three statements in the video make that work on live:
- What is on air.
settings.live.airslists the scenes your stream shows, in order. The player then knows which footage is not on air and plays it from the programme's file. You only passlive.programme.pathwhen you air a different cut. - No jump to live from here. A scene with
access.live: "hold"keeps a viewer who is in the middle of something: their LIVE mark is unavailable (canGoLive: falseinlive:state),live.maxBehindSecondsdoes not count there, and both apply again once they are past the scene. Your owngoLive()still returns them. - Scenes a viewer cannot jump into.
access.viewerSeek(scene access) also covers going to live: a viewer cannot return to live while the broadcast is in a scene closed to them.
What the video cannot do for you: state that must outlive the show (a paid ticket) belongs in your backend, reported when it happens; and an offer closes by the broadcast's time, so refuse a late purchase from a viewer who is behind.
Session videos
Some videos only make sense from their start, on the viewer's own time, with every answer given: a training that begins with a contract, a story whose choices pick a branch. Joined mid-way, or left for live and returned to, they show the viewer a place their own answers never led to. The creator declares such a video with settings.live.mode: "session". You can declare one yourself, per programme, with mode: 'session' in live.programme or setProgramme.
- A viewer on live sees the broadcast's footage. The video's own interactivity is held: no cards, rules or variables of its own. Your own layers, plugins, rules and variables from
overridesrun as usual. - The session is offered to you.
live:statecarriessession: { active, available, reason }andsession:availableis raised. Draw the invitation yourself and callplayerRef.current.startSession(). - A viewer who takes part starts at the beginning, from the programme's file, with fresh state. Inside the session the video behaves exactly as it does as a file.
- There is no jump to live in a session. The controls show no LIVE mark, and
live:statesayscanGoLive: false. The way out ends the session:playerRef.current.endSession()orgoLive()from you, the video's own exit, or the end of the programme. - When a session ends its state is discarded, the viewer is back on live, and
session:endedsays why (left,host,completed,failed). While the same programme is on air they can start again.
A session needs the programme's file and a live.shift of 'auto' or 'file'. Without them available is false and reason says noFile or host. live.maxBehindSeconds does not count in a session: end one yourself when you want it to end. Set live.sessions: false to air such a video as footage only. A viewer in a session sees none of the ad breaks stitched into your stream.
const [session, setSession] = useState({ active: false, available: false })
<MP4EPlayer
ref={playerRef}
attachSource={attachSource}
live={{ programme: { ...programme, mode: 'session' } }}
onEvent={(event, data) => {
if (event === 'live:state') setSession(data.session ?? { active: false, available: false })
}}
/>
{session.available && <button onClick={() => playerRef.current?.startSession()}>Take part from the start</button>}
{session.active && <button onClick={() => playerRef.current?.endSession()}>Leave and return to live</button>}When a live stream ends
When the stream ends and becomes a recording, the player leaves live by itself: the LIVE mark goes, the bar spans the whole recording, and live:ended is raised. A programme and a list of dated overrides keep their times, so a viewer who seeks back in the recording sees the same content at the same moments. A stream that simply stops, with nothing that says so, does not end by itself: call engine.setLive(false).
Events, methods and rules
live:state—{ live, window, edge, behind, atLiveEdge, canSeek, clock, offset, held, programme }, sent when it changes.windowis[start, end]in the player's time, ornull.clockis"stream","estimated"or"none";offsetis what the player adds to the video element's time (0 without a programme);heldis true while timed content waits for a clock or for the programme to begin.programme:ended— playback passed the programme's end ({ title, end }).programme:refused— the programme's start is more than 24 hours back.engine.setProgramme({ start, end, title })changes the programme while playing;nullremoves it.live:ended— the stream is no longer live: it ended and became a recording ({ reason: "streamEnded", duration }), or you said so ({ reason: "host" }).engine.goLive()returns to the live edge;engine.getLiveState()reads the state;engine.setLive(false)says a live programme has ended (many streams simply stop without saying so). In React, passlive={false}.- Rules and plugins can use the action
{ type: "goLive" }and the values{{isLive}},{{behindLive}}(seconds),{{timeShifted}}and{{idleSeconds}}(seconds since the viewer last touched the player), in templates and in conditions. live:left— the viewer is now behind live ({ by, source, behind };byis the action that did it,nullwhen they only fell behind).live:returned— they are back ({ reason }:goLive,cap,resume,programmeEndorcaughtUp).live:shiftLimit— they passedmaxBehindSecondsand are being returned. All three can start a rule.action:blockedon live: the reason islive(skipped, or nowhere to watch from),outsideWindow(the stream no longer holds that moment, or it has not aired yet) orshiftLimit(further back than your limit). A scene's loop is reported with the typesceneLoop.playerRef.current.goLive()returns the viewer to live from your own code.session:available,session:startedandsession:endedcan start a rule, and{{inSession}}is true during a session. The actions{ type: "startSession" }and{ type: "endSession" }do what the methods do.
A live stream has no length: state:duration reports 0. If the stream ends and becomes a recording, the length appears and state:duration reports it. With hls.js, set liveDurationInfinity: true so the element reports a live stream the same way in every browser.
What differs from a file
- Nothing is read from the video's address, so
metadataExtractionPolicydoes not apply and nometadata:warningis raised for it. enableBlobCachehas no effect.media://items and thumbnail previews live inside an MP4E file: name the file withdocumentSrc(or a programme'sfile), or give plugins ordinary URLs. Extra audio tracks inside the file are not played on a stream.- Ad breaks (interstitials) are refused with the reason
stream: a break replaces the video's source, which a stream does not survive. - Subtitles from the stream are drawn by the browser or your player, not by the player's own subtitle styles or subtitle plugins.