Get Media Devices

The MediaStream API provides a way to access device cameras and microphones, which may be used to create media streams to publish into the video rooms. The API also provides information about the devices that can capture and render media.

The iOS SDK provides the following methods:

  • getDevices(): To provide a list of all the microphones connected to your device.
  • getSelectedDevice(): To provide the currently selected/in-use audio device for the stream.

Get a List of Audio Devices

You can initiate a stream by using the browser's default audio device or by specifying the ID of the audio device connected to the device running the client application, which requires you to get the Device IDs of all the connected devices.

The EnxRoom.getDevices() method lists all the microphones connected to your device. You can also use this method to build UI elements, allowing users to choose an audio device from the list.

Class: EnxRoom

Method: -(NSArray*)getDevices

Returns: Device list

Sample Code

NSArray *devicesList = [room getDevices];
// Returns [Speaker, EARPIECE, Headphones, Bluetooth]
// Note: One or many of these devices in array as applicable

Get Selected Audio Device by User

The EnxRoom.getSelectedDevice() method provides the currently selected/in-use audio device for the stream.

Class: EnxRoom

Method: -(NSString*)getSelectedDevice

Sample Code

String selectedDevice = [room getSelectedDevice];
// Returns one of these - Speaker, EARPIECE, Headphones, Bluetooth

Handle Audio Device Updates

Notification about addition or modification in the audio devices, such as earphones or headphones connected to the mobile device is provided through the following callback:

Delegate Method:

-(void)didNotifyDeviceUpdate:(NSString*)updates;: Acknowledgment to the user when a switch to alternate media devices is made at runtime.

Sample Code

- (void)didNotifyDeviceUpdate:(NSString*)updates {
// Device attached or detached
}