-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Error while calling setInputDevice when twilio sdk was instantiated with microphone permissions not granted #228
Comments
@PriscilaAlves thanks for reaching out! This happens because the device ID that you're passing to setInputDevice is not detected. To properly update the internal list of device IDs, you need to grant permissions before initializing the device. For example: // ask permission
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
stream.getTracks().forEach(track => track.stop());
this.twilioDevice = new Device(token, options);
await this.twilioDevice.audio.setInputDevice('default') |
@charliesantos Thanks for the response. I think Twilio SDK should be listening to navigator.permissions state changes and update the availableInputDevices list when the access is granted This is an example of the code that could live inside the audiohelper.js file: const permissionStatus = await navigator.permissions.query({ name: 'microphone' })
if (permissionStatus.state != 'granted') {
permissionStatus.onchange = function () {
//update this.availableInputDevices list
}
} |
@PriscilaAlves thanks for the suggestion. This is a great improvement and we will consider it. |
Closing this now. We're tracking this feature request internally. Please feel free to follow up if needed. |
@PriscilaAlves this is currently in a PR (#283 ) this.twilioDevice = new Device(token, options);
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
stream.getTracks().forEach(track => track.stop());
await this.twilioDevice.audio.setInputDevice('default'); |
or sensitive account information (API keys, credentials, etc.) when reporting this issue.
Code to reproduce the issue:
When the app is opened and Twilio device is initialized, ensure you haven't granted microphone permissions yet.
Then, grant permissions to microphone and only after call
setInputDevice
Expected behavior:
It should succeed to set the input device since the permissions are already granted
Actual behavior:
It fails to set input device with the error:
InvalidArgumentError: Device not found: default
Software versions:
The text was updated successfully, but these errors were encountered: