Class SwitchUserAudio

Switches the user's audio input device based on the provided audio preference.

This method checks for audio permissions, attempts to access the specified audio input device, and updates the application's state accordingly. If the audio input device cannot be accessed, it will revert to the previous audio input device.

The options for switching the user's audio input device.

The preferred audio input device ID.

Additional parameters required for switching the audio input device.

The previous audio input device ID.

Function to show alert messages.

Flag indicating if the user has granted audio permission.

Function to update the user's default audio input device.

Function to handle successful audio stream switch.

Function to request audio permission from the user.

Function to check if media permission is granted.

A promise that resolves when the audio input device has been successfully switched.

Will throw an error if the audio input device cannot be accessed or if there is an unexpected error.

await switchUserAudio({
audioPreference: 'new-audio-device-id',
parameters: {
prevAudioInputDevice: 'previous-device-id',
hasAudioPermission: true,
updateUserDefaultAudioInputDevice: updateDeviceFunction,
// other parameters...
},
});

Constructors

Methods

Constructors

Methods

  • Switches the user's audio input device based on the provided audio preference.

    Parameters

    Returns Promise<void>

    A promise that resolves when the audio input device has been successfully switched.

    Will throw an error if the audio input device cannot be accessed or if there is an unexpected error.