> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions

> CometChat Calling SDK v5 - Actions for JavaScript

Use call actions to create your own custom controls or trigger call functionality dynamically based on your use case. All actions are called on the `CometChatCalls` class during an active call session.

## Audio Controls

### Mute Audio

Mutes your local microphone, stopping audio transmission to other participants.

```javascript theme={null}
CometChatCalls.muteAudio();
```

### Unmute Audio

Unmutes your local microphone, resuming audio transmission.

```javascript theme={null}
CometChatCalls.unMuteAudio();
```

## Video Controls

### Pause Video

Turns off your local camera, stopping video transmission. Other participants see your avatar.

```javascript theme={null}
CometChatCalls.pauseVideo();
```

### Resume Video

Turns on your local camera, resuming video transmission.

```javascript theme={null}
CometChatCalls.resumeVideo();
```

### Switch Camera

Toggles between front and back cameras (on supported devices).

```javascript theme={null}
CometChatCalls.switchCamera();
```

## Screen Sharing

### Start Screen Sharing

Begins sharing your screen with other participants. The browser will prompt the user to select which screen, window, or tab to share.

```javascript theme={null}
CometChatCalls.startScreenSharing();
```

### Stop Screen Sharing

Stops the current screen share.

```javascript theme={null}
CometChatCalls.stopScreenSharing();
```

## Recording

### Start Recording

Begins server-side recording of the call. All participants are notified.

```javascript theme={null}
CometChatCalls.startRecording();
```

<Warning>
  Recording requires the feature to be enabled for your CometChat app.
</Warning>

### Stop Recording

Stops the current recording. The recording is saved and accessible via the dashboard.

```javascript theme={null}
CometChatCalls.stopRecording();
```

## Participant Management

### Mute Participant

Mutes a specific participant's audio. This is a moderator action.

```javascript theme={null}
CometChatCalls.muteParticipant(participantId);
```

| Parameter       | Type   | Description                         |
| --------------- | ------ | ----------------------------------- |
| `participantId` | String | The participant's unique identifier |

### Pause Participant Video

Pauses a specific participant's video. This is a moderator action.

```javascript theme={null}
CometChatCalls.pauseParticipantVideo(participantId);
```

| Parameter       | Type   | Description                         |
| --------------- | ------ | ----------------------------------- |
| `participantId` | String | The participant's unique identifier |

### Pin Participant

Pins a participant to keep them prominently displayed regardless of who is speaking.

```javascript theme={null}
CometChatCalls.pinParticipant(participantId, type);
```

| Parameter       | Type   | Description                         |
| --------------- | ------ | ----------------------------------- |
| `participantId` | String | The participant's unique identifier |
| `type`          | String | The participant type                |

### Unpin Participant

Removes the pin, returning to automatic speaker highlighting.

```javascript theme={null}
CometChatCalls.unpinParticipant();
```

## Layout

### Set Layout

Changes the call layout. Each participant can choose their own layout independently.

```javascript theme={null}
CometChatCalls.setLayout("TILE");
CometChatCalls.setLayout("SIDEBAR");
CometChatCalls.setLayout("SPOTLIGHT");
```

| Value       | Description                                           |
| ----------- | ----------------------------------------------------- |
| `TILE`      | Grid layout with equally-sized tiles                  |
| `SIDEBAR`   | Main speaker with participants in a sidebar           |
| `SPOTLIGHT` | Large view for active speaker, small tiles for others |

## Raise Hand

### Raise Hand

Shows a hand-raised indicator to get attention from other participants.

```javascript theme={null}
CometChatCalls.raiseHand();
```

### Lower Hand

Removes the hand-raised indicator.

```javascript theme={null}
CometChatCalls.lowerHand();
```

## Session Control

### Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.

```javascript theme={null}
CometChatCalls.leaveSession();
```

## UI Controls

### Show Settings Dialog

Opens the settings dialog for audio/video device selection.

```javascript theme={null}
CometChatCalls.showSettingsDialog();
```

### Hide Settings Dialog

Closes the settings dialog.

```javascript theme={null}
CometChatCalls.hideSettingsDialog();
```

### Show Virtual Background Dialog

Opens the virtual background settings dialog.

```javascript theme={null}
CometChatCalls.showVirtualBackgroundDialog();
```

### Hide Virtual Background Dialog

Closes the virtual background dialog.

```javascript theme={null}
CometChatCalls.hideVirtualBackgroundDialog();
```

### Set Chat Button Unread Count

Updates the badge count on the chat button. Pass 0 to hide the badge.

```javascript theme={null}
CometChatCalls.setChatButtonUnreadCount(5);
```

| Parameter | Type   | Description                         |
| --------- | ------ | ----------------------------------- |
| `count`   | Number | The unread message count to display |

## Virtual Background

### Clear Virtual Background

Removes any applied virtual background.

```javascript theme={null}
CometChatCalls.clearVirtualBackground();
```

### Set Virtual Background Blur Level

Applies a blur effect to the background with the specified intensity.

```javascript theme={null}
CometChatCalls.setVirtualBackgroundBlurLevel(10);
```

| Parameter   | Type   | Description              |
| ----------- | ------ | ------------------------ |
| `blurLevel` | Number | The blur intensity level |

### Set Virtual Background Image

Sets a custom image as the virtual background.

```javascript theme={null}
CometChatCalls.setVirtualBackgroundImage("https://example.com/background.jpg");
```

| Parameter  | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| `imageUrl` | String | URL of the background image |

## Device Management

### Get Audio Input Devices

Returns a list of available audio input devices (microphones).

```javascript theme={null}
const audioInputDevices = CometChatCalls.getAudioInputDevices();
console.log(audioInputDevices);
```

### Get Audio Output Devices

Returns a list of available audio output devices (speakers).

```javascript theme={null}
const audioOutputDevices = CometChatCalls.getAudioOutputDevices();
console.log(audioOutputDevices);
```

### Get Video Input Devices

Returns a list of available video input devices (cameras).

```javascript theme={null}
const videoInputDevices = CometChatCalls.getVideoInputDevices();
console.log(videoInputDevices);
```

### Get Current Audio Input Device

Returns the currently selected audio input device.

```javascript theme={null}
const currentAudioInput = CometChatCalls.getCurrentAudioInputDevice();
console.log(currentAudioInput);
```

### Get Current Audio Output Device

Returns the currently selected audio output device.

```javascript theme={null}
const currentAudioOutput = CometChatCalls.getCurrentAudioOutputDevice();
console.log(currentAudioOutput);
```

### Get Current Video Input Device

Returns the currently selected video input device.

```javascript theme={null}
const currentVideoInput = CometChatCalls.getCurrentVideoInputDevice();
console.log(currentVideoInput);
```

### Set Audio Input Device

Sets the audio input device by device ID.

```javascript theme={null}
CometChatCalls.setAudioInputDevice(deviceId);
```

### Set Audio Output Device

Sets the audio output device by device ID.

```javascript theme={null}
CometChatCalls.setAudioOutputDevice(deviceId);
```

### Set Video Input Device

Sets the video input device by device ID.

```javascript theme={null}
CometChatCalls.setVideoInputDevice(deviceId);
```

## Picture-in-Picture

### Enable Picture-in-Picture Layout

Enables Picture-in-Picture mode for the call.

```javascript theme={null}
CometChatCalls.enablePictureInPictureLayout();
```

### Disable Picture-in-Picture Layout

Disables Picture-in-Picture mode.

```javascript theme={null}
CometChatCalls.disablePictureInPictureLayout();
```
