|
| 1 | +--- |
| 2 | +title: Device and permission issues - getSpeakers API doesn't return detailed speaker list |
| 3 | +titleSuffix: Azure Communication Services - Troubleshooting Guide |
| 4 | +description: Learn how to troubleshoot when getSpeakers API doesn't return detailed speaker list. |
| 5 | +author: enricohuang |
| 6 | +ms.author: enricohuang |
| 7 | + |
| 8 | +services: azure-communication-services |
| 9 | +ms.date: 03/28/2024 |
| 10 | +ms.topic: troubleshooting |
| 11 | +ms.service: azure-communication-services |
| 12 | +ms.subservice: calling |
| 13 | +--- |
| 14 | + |
| 15 | +# The getSpeakers API doesn't return detailed speaker list |
| 16 | +If a user reports that they can't see the detailed speaker list, it could be because the application doesn't have permission to access the microphone. |
| 17 | +Alternatively, the platform may not support speaker enumeration. |
| 18 | + |
| 19 | +The way browsers currently work may seem counterintuitive, as the permission to access the microphone can interfere with the enumeration of speakers. |
| 20 | +The speaker and microphone enumeration shares the same permission information. |
| 21 | + |
| 22 | +When the microphone permission state is `prompt` or `denied`, the browser doesn't provide detailed information about the microphone devices and speaker devices. |
| 23 | +In this scenario, [`DeviceManager.getSpeakers`](/javascript/api/azure-communication-services/@azure/communication-calling/devicemanager?view=azure-communication-services-js&preserve-view=true#@azure-communication-calling-devicemanager-getspeakers) API returns an array with one object, where the `id` is set to `speaker:` and the name is set to an empty string. |
| 24 | + |
| 25 | +Some platforms, such as iOS Safari, macOS Safari, or earlier versions of Firefox don't support speaker enumeration. |
| 26 | + |
| 27 | +It's important to note that this scenario is different from the scenario where a user doesn't have any audio output device. |
| 28 | +In the latter case, the [`DeviceManager.getSpeakers`](/javascript/api/azure-communication-services/@azure/communication-calling/devicemanager?view=azure-communication-services-js&preserve-view=true#@azure-communication-calling-devicemanager-getspeakers) API only returns an empty array, indicating that there's no available audio output device in the user's system. |
| 29 | + |
| 30 | +## How to detect using the SDK |
| 31 | +[`DeviceManager.getSpeakers`](/javascript/api/azure-communication-services/@azure/communication-calling/devicemanager?view=azure-communication-services-js&preserve-view=true#@azure-communication-calling-devicemanager-getspeakers) API returns an empty array or an array with an object, where the `id` is set to `speaker:` and the name is set to an empty string. |
| 32 | + |
| 33 | +Additionally, to detect the scenario where the user removes the speaker during the call and there are no available audio output devices in the system, the application can listen to the `noSpeakerDevicesEnumerated` event being raised to true in the [User Facing Diagnostics Feature](../../../../concepts/voice-video-calling/user-facing-diagnostics.md). This event can help the application understand the current situation, and show the warning message on its UI accordingly. |
| 34 | + |
| 35 | +For the platform that doesn't support speaker enumeration, you get an error when calling [`DeviceManager.getSpeakers`](/javascript/api/azure-communication-services/@azure/communication-calling/devicemanager?view=azure-communication-services-js&preserve-view=true#@azure-communication-calling-devicemanager-getspeakers) API. |
| 36 | + |
| 37 | +The error code/subcode is |
| 38 | + |
| 39 | +| error | Details | |
| 40 | +|------------------|-------------------------------------------------------| |
| 41 | +| code | 405 (Method Not Allowed) | |
| 42 | +| subcode | 40606 | |
| 43 | +| message | This device doesn't support speaker enumeration. | |
| 44 | +| resultCategories | Expected | |
| 45 | + |
| 46 | +## How to mitigate or resolve |
| 47 | +The application should always call the `DeviceManager.askDevicePermission` API to ensure that the required permissions are granted. |
| 48 | +If the user doesn't grant the microphone permission, the application should show a warning on its user interface, so the user knows that they aren't able to see the speaker device list. |
| 49 | + |
| 50 | +The application should also check whether the speaker list is empty or handle the error when calling [`DeviceManager.getSpeakers`](/javascript/api/azure-communication-services/@azure/communication-calling/devicemanager?view=azure-communication-services-js&preserve-view=true#@azure-communication-calling-devicemanager-getspeakers) API, and show a warning accordingly. |
| 51 | +Additionally, the application should listen to the `noSpeakerDevicesEnumerated` event and show a message when there are no available speaker devices. |
0 commit comments