Saving & Uploads - Express Capture 2.0
Saving & Uploads
After recording, the review screen always offers both Download a Copy and Use This. The user can do one, the other, or both.
- Download a Copy saves the recording to the user's device. It is purely local and sends no event to your page. Files are named
rec-<YYYYMMDD-HHMM>from the time the recording finished, with an.mp4or.webmextension depending on what the browser recorded. - Use This always hands the recording to your page through the
onUseThisSelectedevent. What else it does depends onrecorderConfig.saveMode.
Save Modes
saveMode | What Use This does |
|---|---|
'kaltura' (default) | Fires onUseThisSelected, then uploads to Kaltura. |
'non_kaltura' | Fires onUseThisSelected and makes no network call at all. |
onUseThisSelected fires before the upload starts and whatever its outcome. So even if the upload fails, your page still holds the recording. That is also why the event carries no entry ID: the entry doesn't exist yet. Wait for onUploadComplete to get it.
Upload to Kaltura
With saveMode: 'kaltura', the recorder:
- Creates a new media entry named from
entryName(or a generated name), with the admin tagexpressrecorder. - Uploads the recording to it, applying
conversionProfileIdif you set one. - Fires
onUploadCompleteonce the upload succeeds, listing the entry it created. A screen share with the camera on creates two entries, and the event fires once both have uploaded. See Upload Results.
onUploadComplete never fires for an upload that failed or was cancelled.
Replace an Existing Entry's Media
Set recorderConfig.entryId to upload the recording as new media on an entry that already exists, instead of creating one:
recorderConfig: {
saveMode: 'kaltura',
entryId: '1_abc123',
}
The recorder never deletes this entry, even when the user cancels the upload. In a screen share with the camera on, the screen replaces this entry's media and the camera still goes to a new child entry. See Screen Sharing.
Keep Recordings Out of Kaltura
Set saveMode: 'non_kaltura' to handle the media yourself, for example to send it to your own storage:
runtime.onUseThisSelected.on(({ cameraBlob, screenBlob, fileName, mimeType, size }) => {
const blob = screenBlob ?? cameraBlob;
// send `blob` to your own backend
});
In this mode nothing is uploaded and onUploadComplete never fires.
Show Your Own Upload Progress
Set showUploadUI: false to hide the recorder's progress bar and done screen. The upload still runs; use onUploadComplete to know when it has finished.
Keep the Page Open During Upload
The upload runs in the page. If the user closes or reloads the page before it finishes, the upload is lost.
The recorder asks the browser to warn the user before leaving only while recording, including while paused. It doesn't warn during the countdown, on the review screen, or while uploading.
To protect uploads, add your own warning from Use This until onUploadComplete, which fires only once every entry has uploaded:
const warn = (e) => { e.preventDefault(); e.returnValue = ''; };
runtime.onUseThisSelected.on(() => {
// Under saveMode 'non_kaltura' nothing uploads, so skip this there.
window.addEventListener('beforeunload', warn);
});
runtime.onUploadComplete.on(() => window.removeEventListener('beforeunload', warn));
// A failed or cancelled upload fires no event, so also remove the
// warning when the next recording starts.
runtime.onRecordingStarted.on(() => window.removeEventListener('beforeunload', warn));
In an iframe, do the same with the useThisSelected, uploadComplete and recordingStarted messages; see Iframe Embedding.
In production today, onUploadComplete fires once per entry, so a screen share with the camera on fires it after the screen uploads, while the camera is still uploading. To keep the warning on until both have uploaded, count the entries:
let pending = 0;
runtime.onUseThisSelected.on(({ cameraBlob, screenBlob }) => {
pending = cameraBlob && screenBlob ? 2 : 1;
window.addEventListener('beforeunload', warn);
});
runtime.onUploadComplete.on((payload) => {
// One event lists every entry; production today sends one event per entry.
pending = payload.entries ? 0 : pending - 1;
if (pending <= 0) window.removeEventListener('beforeunload', warn);
});
This version works both now and after the next release. In an iframe, the blobs it counts arrive only with ?parentOrigin=.