Skip to main content

smwebsdk.scene.setmediadeviceactive

Home > @soulmachines/smwebsdk > Scene > setMediaDeviceActive

Scene.setMediaDeviceActive() method

On success, starts or stops streaming video/audio to the server based on the values of microphone and camera.

Signature:

setMediaDeviceActive(options: {
microphone?: boolean;
camera?: boolean;
}): Promise<void>;

Parameters

ParameterTypeDescription
options{ microphone?: boolean; camera?: boolean; }

Returns:

Promise<void>

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:

{
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:

scene.setMediaDeviceActive({ microphone: true, camera: false })
.then(console.log('microphone activated, camera deactivated'));
.catch((error) => console.log('error occurred: ', error);