-
Notifications
You must be signed in to change notification settings - Fork 2
AudioDeviceManager
void setAudioDeviceEventListener(AudioDeviceEventListener audioDeviceEventListener)AudioDeviceEventListener getAudioDeviceEventListener()AudioDevice getActiveDevice()Set<AudioDevice> getAvailableAudioDevices()void selectAudioDevice(AudioDevice audioDevice) throws MissingPermissionsException
Configures event handler to handle audio device changes events.
-
audioDeviceEventListener:AudioDeviceEventListener- An interface that should be implemented in order to properly handle audio device changes.
N/A
private void example() {
// Obtain the token and initialize the InfobipRTC instance
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
// Get the active application call
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
// Get the audio device manager from the application call
AudioDeviceManager audioDeviceManager = applicationCall.audioDeviceManager();
// Set the audio device event listener
audioDeviceManager.setAudioDeviceEventListener(new AudioDeviceEventListener() {
@Override
public void onActiveAudioDeviceChanged(@NonNull ActiveAudioDeviceChangedEvent activeAudioDeviceChangedEvent) {
// Handle the active audio device change event
String name = activeAudioDeviceChangedEvent.getActiveAudioDevice().getName();
Log.d("WebRTC", String.format("Active audio device changed, now using %s", name));
}
@Override
public void onAvailableAudioDevicesChanged(@NonNull AvailableAudioDevicesChangedEvent availableAudioDevicesChangedEvent) {
// Handle the available audio devices change event
Log.d("WebRTC", "Available audio devices list updated.");
updateListOfAvailableAudioDevices(availableAudioDevicesChangedEvent.getAvailableAudioDevices());
}
});
}Retrieves the event handler for audio device change events.
none
-
AudioDeviceEventListener- An interface that should be implemented to properly handle audio device changes.
// Obtain the token and initialize the InfobipRTC instance
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
// Get the active application call
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
// Get the audio device manager from the application call
AudioDeviceManager audioDeviceManager = applicationCall.audioDeviceManager();
// Get the audio device event listener
AudioDeviceEventListener audioDeviceEventListener = audioDeviceManager.getAudioDeviceEventListener();Retrieves the active audio device currently in use during the call. It may return null during call initialization.
Please note that the active audio device can change if a new device is connected or the current device is disconnected.
In such cases, the onActiveAudioDeviceChanged method will
be triggered to notify you about the new active device.
none
-
AudioDevice- An object representing the currently used audio device.
// Obtain the token and initialize the InfobipRTC instance
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
// Get the active application call
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
// Get the audio device manager from the application call
AudioDeviceManager audioDeviceManager = applicationCall.audioDeviceManager();
// Get the active device
AudioDevice activeDevice = audioDeviceManager.getActiveDevice();Retrieves a set of available audio devices sorted by the priority order. Please note that the set of available audio
devices can change if a new device is connected or the current device is disconnected. In such cases,
the onAvailableAudioDevicesChanged method will be
triggered to notify you about the new available devices.
none
-
Set<AudioDevice>- A set containing the currently available audio devices sorted by the priority order.
// Obtain the token and initialize the InfobipRTC instance
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
// Get the active application call
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
// Get the audio device manager from the application call
AudioDeviceManager audioDeviceManager = applicationCall.audioDeviceManager();
// Get the available devices
Set<AudioDevice> availableAudioDevices = audioDeviceManager.getAvailableAudioDevices();Changes the currently active audio device to the specified audio device. If the selected audio device is available, it
becomes the active device. When the call ends, the selected audio device is reset to the default device. Please be aware
that the active audio device can be changed if a new device is connected or the current device is disconnected. In such
cases, the onActiveAudioDeviceChanged event will be
triggered to notify you about the new active device.
-
audioDevice:AudioDevice- The audio device to be set as active.
N/A
-
MissingPermissionsException- This exception is thrown when the required permission is not granted. It contains a descriptive message explaining the issue.
On Android 12 or higher, the
BLUETOOTH_CONNECTpermission is required. Make sure to grant this permission before making the call. There is no need to request this permission on Android 11 or lower. To understand the required permissions better, refer to ourpermissions tutorial.
private void example() {
// Obtain the token and initialize the InfobipRTC instance
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
// Get the active application call
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
// Get the audio device manager from the application call
AudioDeviceManager audioDeviceManager = applicationCall.audioDeviceManager();
// Get the list of available audio devices
List<AudioDevice> availableAudioDevices = new ArrayList<>(audioDeviceManager.getAvailableAudioDevices());
try {
// Select the first available audio device
AudioDevice audioDevice = availableAudioDevices.get(0);
audioDeviceManager.selectAudioDevice(audioDevice);
} catch (MissingPermissionsException e) {
Log.e("WebRTC", String.format("Error setting active device: %s", e.getMessage()));
}
}