Methods

Methods are essential for controlling the call. You may want to enable or disable cameras, microphones, start screen sharing, control recordings, etc...

Before you start using methods, first you need to initialize the SDK and load the room through the DigitalSambaEmbedded class. After that you can use the sambaFrame (or whatever variable name you have chosen) to call methods and control the rooms experience.

Subscribing to the userJoined event is a crucial part. If you try to call methods (apart from load and event subscription) while user hasn't joined the room yet, then calling the methods won't do anything. For example -> you cannot possibly enable user's camera if he hasn't joined the room yet.

Sample quick-start code:

const initOptions = {team: 'myTeamNameHere', room: 'myRoomNameHere'};
const sambaFrame = DigitalSambaEmbedded.createControl(initOptions);

sambaFrame.on('userJoined', (event) => {
  const data = event.data;
  if (data.type === 'local') {
     console.log('You have joined the room');     
     //You can freely call methods from now on, since user is inside the room
     //For example you can hide the toolbar if you want
     sambaFrame.hideToolbar();
  } else {
     console.log(data.user.name, 'has joined the room');
  }
});

//Load the room when you need according to your application logic
sambaFrame.load();

Last updated