The Digital Samba SDK lets you add a complete video conference to your own application with a few lines of JavaScript, and then control it programmatically: joining rooms, muting microphones, toggling cameras, sharing screens, recording sessions and more, all from your own interface.
This tutorial shows you how to embed the Digital Samba video room in your application and control it with the SDK. You will learn how to:
Table of Contents
Initialising the SDK requires a room URL, which has the form https://[your-team].digitalsamba.com/[room-name]. You can get it through the dashboard or the Digital Samba API. Here's how to do both:
1. Go to https://dashboard.digitalsamba.com/ and click "Rooms" in the left sidebar.
2. You'll see any rooms you've created. By default, there's a "demo-room". You can also create a new room by clicking "Create new room".
3. Make your desired configurations and click "Create room".
4. Copy the room link by clicking "Copy link", and you have everything the SDK needs.
1. Make a GET request to list your rooms:
curl --request GET \ --url https://api.digitalsamba.com/api/v1/rooms \ --user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY
Replace YOUR_TEAM_ID and YOUR_DEVELOPER_KEY with the values from the Team section of your dashboard. We cover this in more detail in our guide to configuring team settings with the developer API.
2. In the response, find the friendly_url of the room you want. It sits inside the data array:
{
"total_count": 6124,
"data": [
{
"id": "c39d7c40-7ff7-4faa-b06f-698a639a9523",
"friendly_url": "my-test-meeting",
"privacy": "public"
}
]
}
3. Append the friendly_url to your team domain to form the full room URL:
https://your-team.digitalsamba.com/my-test-meeting
For more details on room management, such as creation and editing, see the Digital Samba API docs.
The SDK is distributed as the npm package @digitalsamba/embedded-sdk. There are two ways to add it to your project: from a CDN for quick prototyping, or via npm for production use (SDK documentation).
To try the SDK quickly, load it with a script tag from the unpkg public CDN:
<script crossorigin src="https://unpkg.com/@digitalsamba/embedded-sdk"></script>
For production integrations, install the package with your preferred package manager and use a bundler such as webpack.
npm:
npm install @digitalsamba/embedded-sdk
Or with Yarn:
yarn add @digitalsamba/embedded-sdk
After installing, import the SDK in your application code:
import DigitalSambaEmbedded from '@digitalsamba/embedded-sdk';
The SDK is written in TypeScript, so type definitions are available out of the box.
To join, initialise the SDK with the room URL from earlier and call load(). The SDK creates an iframe for the room and appends it to the page body:
import DigitalSambaEmbedded from '@digitalsamba/embedded-sdk';
const roomUrl = 'https://your-team.digitalsamba.com/my-test-meeting';
const sambaFrame = DigitalSambaEmbedded.createControl({ url: roomUrl });
sambaFrame.load();
Instead of a full URL, you can also pass team and room as separate options, render the room inside a specific element with root, or load it into an existing iframe with frame. For private rooms, pass a JWT in the optional token option (see the tokens documentation). All valid option combinations are listed in the DigitalSambaEmbedded class documentation.
With the room loaded, you can wire the SDK's methods to your own interface. One caveat before you start: apart from load() and event subscriptions, method calls do nothing until the local user has joined the room, so trigger your controls once the userJoined event fires for the local user. The audio and video toggles are the exception: called before joining, they set the user's join defaults instead. In this tutorial we cover the essential controls:
Muting is the control users reach for most, whether to cut background noise or to hand the floor to someone else. To mute the local user's microphone, call disableAudio():
sambaFrame.disableAudio();
To unmute, call enableAudio():
sambaFrame.enableAudio();
Toggling the camera is useful for privacy and for saving bandwidth. To turn the camera on, call enableVideo():
sambaFrame.enableVideo();
To turn it off, call disableVideo():
sambaFrame.disableVideo();
Screen sharing covers two separate things in the SDK: granting permission, and actually sharing.
Allow or disallow screen share
To grant screen-share permission to a participant, call allowScreenshare() with that user's ID. This is handy in webinar scenarios, where some roles cannot share by default:
sambaFrame.allowScreenshare('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
To revoke it, call disallowScreenshare(); it only takes effect if allowScreenshare() was previously called for that user:
sambaFrame.disallowScreenshare('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
Start or stop screen share
To start sharing the local user's screen, call startScreenshare():
sambaFrame.startScreenshare();
To stop, call stopScreenshare():
sambaFrame.stopScreenshare();
You can record the meeting to Digital Samba's cloud storage and collect the resulting mp4 file afterwards through the dashboard or the recordings API. Note that the call is ignored if recordings are not enabled for the room or a recording is already in progress.
To start recording, call startRecording():
sambaFrame.startRecording();
To stop recording, call stopRecording():
sambaFrame.stopRecording();
Virtual backgrounds give users privacy and tidy up whatever sits behind them. To switch one on for the local user, call enableVirtualBackground(), an alias of configureVirtualBackground() below, with the options you want:
sambaFrame.enableVirtualBackground({blur: 'balanced'});
To remove it, call disableVirtualBackground():
sambaFrame.disableVirtualBackground();
To set or change the background with specific options, use configureVirtualBackground(). Either the blur, image or imageUrl field must be specified, and the optional enforce parameter, when true, stops the local user changing the background manually once inside the room:
// Strong blur for the local user
sambaFrame.configureVirtualBackground({blur: 'strong'});
// Balanced blur, enforced so the user cannot change it in the room
sambaFrame.configureVirtualBackground({blur: 'balanced', enforce: true});
// One of the predefined images
sambaFrame.configureVirtualBackground({image: 'forest'});
// An image from a public URL
sambaFrame.configureVirtualBackground({imageUrl: 'https://example.com/background.jpg'});
To see who is currently in the meeting, call listUsers(), which returns an array of the users inside the room with their IDs, names and roles:
let users = sambaFrame.listUsers();
console.log('There are', users.length, 'users inside the room:');
console.log(users);
If you want an always up-to-date list, subscribe to the usersUpdated event instead; the events reference lists everything you can subscribe to. For role changes, tile control and moderating other participants, see our guide to selecting and switching participants in a video call.
These two methods look similar but behave very differently. leaveSession() removes only the local user while the meeting continues for everyone else:
sambaFrame.leaveSession();
endSession() ends the call for all participants. By default it shows a confirmation popup first; pass false to skip the confirmation and end immediately:
// Ends the session after a confirmation modal sambaFrame.endSession(); // Ends the session immediately, without confirmation sambaFrame.endSession(false);
To explore the full method catalogue, from whiteboards to recording bookmarks, browse the SDK methods documentation. If you want to control room features server-side as well, our guides to enabling the whiteboard via the API and using webhooks are good next steps.
Only for private rooms. The token option accepts a JWT and is mainly used for authentication in private rooms; public rooms can be joined with just the room URL.
Yes. Pass an existing iframe with the frame option, or a parent element with the root option, and the SDK renders the room there instead of appending an iframe to the page body.
leaveSession() removes only the local user from the meeting, while endSession() ends the call for everyone. endSession() shows a confirmation popup by default, which you can skip by passing false.
Recordings are stored in Digital Samba's cloud storage. Once stopped and processed, the mp4 file is available in your team dashboard and through the recordings API.
Yes. The SDK is written in TypeScript and ships with type definitions in the @digitalsamba/embedded-sdk npm package.
With Digital Samba Embedded, adding video conferencing to your product comes down to one package, one room URL and a load() call, and the SDK's methods then put every control, from muting to recording to virtual backgrounds, in your own interface. Create a developer account and try it with your own room.