> ## 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.

# Device Management

> CometChat Calling SDK v5 - Device Management for JavaScript

Manage audio and video devices during calls, including selecting microphones, speakers, and cameras.

## Get Available Devices

### Audio Input Devices (Microphones)

Get a list of available microphones:

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

### Audio Output Devices (Speakers)

Get a list of available speakers:

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

### Video Input Devices (Cameras)

Get a list of available cameras:

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

## Get Current Device

### Current Audio Input Device

Get the currently selected microphone:

```javascript theme={null}
const currentMic = CometChatCalls.getCurrentAudioInputDevice();
console.log("Current microphone:", currentMic);
```

### Current Audio Output Device

Get the currently selected speaker:

```javascript theme={null}
const currentSpeaker = CometChatCalls.getCurrentAudioOutputDevice();
console.log("Current speaker:", currentSpeaker);
```

### Current Video Input Device

Get the currently selected camera:

```javascript theme={null}
const currentCamera = CometChatCalls.getCurrentVideoInputDevice();
console.log("Current camera:", currentCamera);
```

## Change Device

### Set Audio Input Device

Switch to a different microphone:

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

### Set Audio Output Device

Switch to a different speaker:

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

### Set Video Input Device

Switch to a different camera:

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

## Device Change Events

### Device Selection Changed

Monitor when the selected device changes:

```javascript theme={null}
CometChatCalls.addEventListener("onAudioInputDeviceChanged", (device) => {
  console.log("Microphone changed:", device);
});

CometChatCalls.addEventListener("onAudioOutputDeviceChanged", (device) => {
  console.log("Speaker changed:", device);
});

CometChatCalls.addEventListener("onVideoInputDeviceChanged", (device) => {
  console.log("Camera changed:", device);
});
```

### Available Devices Changed

Monitor when devices are connected or disconnected:

```javascript theme={null}
CometChatCalls.addEventListener("onAudioInputDevicesChanged", (devices) => {
  console.log("Available microphones updated:", devices);
});

CometChatCalls.addEventListener("onAudioOutputDevicesChanged", (devices) => {
  console.log("Available speakers updated:", devices);
});

CometChatCalls.addEventListener("onVideoInputDevicesChanged", (devices) => {
  console.log("Available cameras updated:", devices);
});
```

## Settings Dialog

Open the built-in settings dialog for device selection:

```javascript theme={null}
// Show settings dialog
CometChatCalls.showSettingsDialog();

// Hide settings dialog
CometChatCalls.hideSettingsDialog();
```

## Device Object

Each device object contains:

| Property   | Type   | Description                                             |
| ---------- | ------ | ------------------------------------------------------- |
| `deviceId` | String | Unique identifier for the device                        |
| `label`    | String | Human-readable device name                              |
| `kind`     | String | Device type (`audioinput`, `audiooutput`, `videoinput`) |
