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 Android SDK provides the following methods:

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

Get a List of All Microphones

You can initiate a stream using either 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 provides a list of all the microphones connected to your device. You can also use this method to build UI element allowing users to choose an audio device from the list.

Class: EnxRoom

Method: public List <String> getDevices()

Returns: List of devices

Sample Code

List deviceList = enxRoom.getDevices();

Get the Selected Audio Device by User

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

Class: EnxRoom

Method: public String getSelectedDevice()

Sample Code

String selectedDevice = room.getSelectedDevice();

Handle Audio Device Updates

In the event of addition or modification in the audio devices, such as earphones or headphones connected to the mobile device, the change is notified through the following callbacks:

Callback NameDescription
onNotifyDeviceUpdateAcknowledgment to the user when a switch to alternate media devices is made at runtime.
onDeviceAddedNotification to the user when a new audio device is connected.
onDeviceRemovedNotification to the user when an audio device is disconnected.

Sample Code

public void onDeviceAdded(String message) {
// New Device added
public void onDeviceRemoved(String message) {
// Device removed
public void onNotifyDeviceUpdate (String message) {
// Device switched