The following APIs allow you to switch to alternate Media Devices after having published Stream, thus facilitating a switch on the fly.

Table of Contents

Switch between Rear & Front Camera

The EnxStream.switchCamera() method allows you to switch between Rear and Front Camera as a source for the published Stream.

Class: EnxStream

Method: public void switchCamera() – No parameter required.


Error Codes / Exceptions

5021Unable to switch Camera in Audio-only call mode.
5097Unable to switch Camera in a Chat-Only Room. Non-Contextual Method Call.

Switch to alternate Microphone

The EnxRoom.switchMediaDevice() method is used to switch the Audio source of the published Stream to an alternate Microphone. This method requires ID of the Audio device to switch to, which needs to be retrieved using EnxRoom.getDevices() method.

Class: EnxRoom

Method: public void switchMediaDevice(String micDeviceId)

Parameters: micDeviceId – String. Target Microphone Device ID.

Observer: onNotifyDeviceUpdate – Acknowledgment sent with the new Audio Device ID after Audio Device update is complete.

room.switchMediaDevice( micDeviceId );

public void onNotifyDeviceUpdate( String micDeviceId ) {
      // Switched to micDeviceId