<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@soulmachines/smwebsdk](./smwebsdk.md) &gt; [Scene](./smwebsdk.scene.md) &gt; [setMediaDeviceActive](./smwebsdk.scene.setmediadeviceactive.md)

## Scene.setMediaDeviceActive() method

On success, starts or stops streaming video/audio to the server based on the values of `microphone` and `camera`<!-- -->.

**Signature:**

```typescript
setMediaDeviceActive(options: {
        microphone?: boolean;
        camera?: boolean;
    }): Promise<void>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  options | { microphone?: boolean; camera?: boolean; } |  |

**Returns:**

Promise&lt;void&gt;

Returns a promise which is fulfilled when the media active state has been successfully changed. \\ If the session is not defined it will return `undefined`<!-- -->. \\ If the active state could not be changed, the promise is rejected with an Error object having the format:

```javascript
{
  message: string;
  name: errorCode;
}
```
Where `errorCode` is one of: - `noUserMedia` - the microphone/camera is either not available, not usable or the user declined permission to use them - `failedUpgrade` - the media upgrade failed - `notSupported` - user’s browser does not support the getUserMedia API - `noConnection` - connection has not been established - ensure scene.connect() has been called previously

Usage:

```javascript
scene.setMediaDeviceActive({ microphone: true, camera: false })
  .then(console.log('microphone activated, camera deactivated'));
  .catch((error) => console.log('error occurred: ', error);
```

