# 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](https://docs.digitalsamba.com/reference/sdk/digitalsambaembedded-class). After that you can use the **sambaFrame** (or whatever variable name you have chosen) to call methods and control the rooms experience.

{% hint style="danger" %}
Subscribing to the [userJoined](https://docs.digitalsamba.com/reference/sdk/events/userjoined) event is a crucial part. If you try to call methods (apart from [load](https://docs.digitalsamba.com/reference/sdk/methods/load) and [event subscription](https://docs.digitalsamba.com/reference/sdk/methods/on)) 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.
{% endhint %}

#### Sample quick-start code:

```javascript
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();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalsamba.com/reference/sdk/methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
