A user may want to switch to alternate Media Devices for his published stream. EnableX API allows Media Device switching on the fly.

Table of Contents

The APIs allows you to switch between Rear and Front Camera and to alternate available Microphone.

Switch between Rear & Front Camera

If user looks to switch between Rear and Front Camera as a source for published Stream, use Enx.switchCamera() method.

Method: Enx.switchCamera(localStreamId)

Parameters: localStreamId – String, Local Stream Id whose source camera is being switched

Enx.switchCamera(localStreamId);

Switch to alternate Microphone

If user looks to switch Micrcophone used to create published Stream to an alternate Microphone, use Enx.switchMediaDevice() method. This API requires new device name to switch to. You can use Enx.getDevices() method to fetch a list of microphone names and create a UI for new device selection.

Method: Enx.switchMediaDevice(micDevice)

Parameters: micDevice – String, New Microphone Device name

Callback: notifyDeviceUpdate – When Audio Device Update is complete. Returns with switched Microphone Device

Enx.switchMediaDevice( micDevice ); // To switch to new micDev

// To self: Device updated
notifyDeviceUpdate : event =>{
	// event = micDevice name
}