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: - (NSException*) switchCamera;

[localstream switchCamera];

Error Code / Exceptions

CodeDescription
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 name of the Audio device to switch to, which needs to be retrieved using EnxRoom.getDevices() method.

Class: EnxRoom

Method: – (void)switchMediaDevice:(NSString *)mediaName

Parameters: mediaName – String. Target Microphone Device Name.

Delegate Method: - didNotifyDeviceUpdate: – Acknowledgment sent with the new Audio Device ID after Audio Device update is complete.

[room switchMediaDevice:@”mediaName”];

-(void)didNotifyDeviceUpdate:(NSString *)updates{
	// updates carry new device name
}