Getting Started - Express Capture 2.0
Getting Started
You need:
- A KS (Kaltura Session string) that can create entries for your partner. See the Session Guide.
- Your partner ID.
- A player uiConf ID, used to play the recording back on the review screen. See the Kaltura Player.
Replace the three values in the file below and serve it over HTTPS (or from localhost), since browsers allow camera, microphone and screen capture only on secure pages.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Express Capture 2.0</title>
</head>
<body>
<p id="status">Loading…</p>
<div id="recorder" style="width: 800px; height: 450px;"></div>
<script type="module">
const ks = 'YOUR_KS_TOKEN';
const partnerId = Number('YOUR_PARTNER_ID');
const uiConfId = Number('YOUR_UICONF_ID');
const status = document.getElementById('status');
if (ks === 'YOUR_KS_TOKEN' || isNaN(partnerId) || isNaN(uiConfId)) {
status.textContent = 'Replace YOUR_KS_TOKEN, YOUR_PARTNER_ID and YOUR_UICONF_ID with real values to get started.';
} else {
const { createWorkspace } = await import(
'https://unisphere.nvp1.ovp.kaltura.com/v1/loader/index.esm.js'
);
const workspace = await createWorkspace({
config: {
appId: 'my-app',
appVersion: '1.0.0',
env: 'nvp1',
experiences: {
recorder: {
recorder: {
settings: {
ks,
partnerId,
uiConfId,
serviceUrl: 'https://www.kaltura.com',
playerUrl: 'https://cdnapisec.kaltura.com',
},
},
},
},
ui: { theme: 'light', language: 'en' },
},
workspaceName: 'my-workspace',
});
const runtime = await workspace.getRuntimeAsync(
'unisphere.widget.recorder',
'recorder'
);
if (!runtime) {
status.textContent = 'Failed to load the recorder runtime.';
} else {
status.textContent = '';
runtime.mountVisual({
type: 'contained',
target: { type: 'element', elementId: 'recorder' },
settings: {},
});
runtime.onUploadComplete.on((payload) => {
const [first] = payload.entries ?? [payload];
status.textContent = `Uploaded as entry ${first.entryId}`;
});
}
}
</script>
</body>
</html>
The recorder appears inside the #recorder element. Record, review, and click Use This to upload the recording to Kaltura as a new entry.
What Just Happened
- The loader script downloads the recorder widget from the Kaltura CDN.
createWorkspaceregisters therecorderruntime with your settings.envis required: the region the workspace runs in. The settings are validated, and the recorder fails to load if a required one is missing.getRuntimeAsyncresolves once the widget is ready.mountVisualrenders the recorder into the#recorderelement.onUploadCompletereports the new entry ID once the upload finishes.payload.entries ?? [payload]reads the entries from both the current and the coming event shape; see Upload Results.
Size the Container
The recorder fills the element you give it, so that element must have an explicit width and height. Keep it at the capture's aspect ratio: 16:9 for the default landscape orientation, 9:16 for portrait. If you let users switch orientation, resize the element when they do; see Events.
To remove the recorder later, keep the object mountVisual returns and pass its id to unmountVisual:
const visual = runtime.mountVisual({ /* ... */ });
// later
runtime.unmountVisual(visual.id);
Choose a Region
Use your account's region in three places: the loader URL, env, and serviceUrl. The loader and env must match, or the workspace fails to start. See Endpoints & Regions.
| Region | Loader host | env | serviceUrl |
|---|---|---|---|
| US | unisphere.nvp1.ovp.kaltura.com | nvp1 | https://www.kaltura.com |
| Frankfurt (DE) | unisphere.frp2.ovp.kaltura.com | frp2 | https://api.de.kaltura.com |
| Ireland (EU) | unisphere.irp2.ovp.kaltura.com | irp2 | https://api.eu.kaltura.com |
serviceUrl is the API host without /api_v3.
Next Steps
- Settings — Turn off capabilities, cap the recording length, rename entries
- Saving & Uploads — Keep recordings out of Kaltura, or replace an existing entry's media
- Events — React to recordings in your page
- Examples — Ready-to-use configurations