|
1 | 1 | ---
|
2 |
| -title: Quickstart - Add volume indicator to your Web calling app |
| 2 | +ms.author: chengyuanlai |
| 3 | +title: Quickstart - Get audio stream volume in your calling app |
3 | 4 | titleSuffix: An Azure Communication Services quickstart
|
4 |
| -description: In this quickstart, you'll learn how to check call volume within your Web app when using Azure Communication Services. |
| 5 | +description: In this quickstart, you'll learn how to check call volume within your Calling app when using Azure Communication Services. |
5 | 6 | author: sloanster
|
6 |
| - |
7 |
| -ms.author: micahvivion |
8 |
| -ms.date: 1/18/2023 |
| 7 | +services: azure-communication-services |
| 8 | +ms.date: 03/26/2024 |
9 | 9 | ms.topic: quickstart
|
10 | 10 | ms.service: azure-communication-services
|
11 | 11 | ms.subservice: calling
|
| 12 | +zone_pivot_groups: acs-plat-web-ios-android-windows |
12 | 13 | ms.custom: mode-other
|
13 | 14 | ---
|
14 | 15 |
|
15 |
| -# Accessing call volume level |
16 |
| -As a developer you can have control over checking microphone volume in JavaScript. This quickstart shows examples of how to accomplish this within the Azure Communication Services WebJS. |
17 |
| - |
18 |
| -## Prerequisites |
19 |
| ->[!IMPORTANT] |
20 |
| -> The quick start examples here are available starting in version [1.13.1](https://www.npmjs.com/package/@azure/communication-calling/v/1.13.1) of the calling Web SDK. Make sure to use that SDK version or newer when trying this quickstart. |
| 16 | +# Quickstart: Access call volume level in your calling app |
21 | 17 |
|
22 |
| -## Checking the audio stream volume |
23 |
| -As a developer it can be nice to have the ability to check and display to end users the current local microphone volume or the incoming microphone level. Azure Communication Services calling API exposes this information using `getVolume`. The `getVolume` value is a number ranging from 0 to 100 (with 0 noting zero audio detected, 100 as the max level detectable). This value is sampled every 200 ms to get near real time value of volume level. |
| 18 | +::: zone pivot="platform-windows" |
| 19 | +[!INCLUDE [Access call volume level with Windows](./includes/volume-indicator/volume-indicator-windows.md)] |
| 20 | +::: zone-end |
24 | 21 |
|
25 |
| -### Example usage |
26 |
| -This example shows how to generate the volume level by accessing `getVolume` of the local audio stream and of the remote incoming audio stream. |
| 22 | +::: zone pivot="platform-android" |
| 23 | +[!INCLUDE [Access call volume level with Android](./includes/volume-indicator/volume-indicator-android.md)] |
| 24 | +::: zone-end |
27 | 25 |
|
28 |
| -```javascript |
29 |
| -//Get the volume of the local audio source |
30 |
| -const volumeIndicator = await new SDK.LocalAudioStream(deviceManager.selectedMicrophone).getVolume(); |
31 |
| -volumeIndicator.on('levelChanged', ()=>{ |
32 |
| - console.log(`Volume is ${volumeIndicator.level}`) |
33 |
| -}) |
| 26 | +::: zone pivot="platform-ios" |
| 27 | +[!INCLUDE [Access call volume level with iOS](./includes/volume-indicator/volume-indicator-ios.md)] |
| 28 | +::: zone-end |
34 | 29 |
|
35 |
| -//Get the volume level of the remote incoming audio source |
36 |
| -const remoteAudioStream = call.remoteAudioStreams[0]; |
37 |
| -const volumeIndicator = await remoteAudioStream.getVolume(); |
38 |
| -volumeIndicator.on('levelChanged', ()=>{ |
39 |
| - console.log(`Volume is ${volumeIndicator.level}`) |
40 |
| -}) |
41 |
| -``` |
| 30 | +::: zone pivot="platform-web" |
| 31 | +[!INCLUDE [Access call volume level with JavaScript](./includes/volume-indicator/volume-indicator-javascript.md)] |
| 32 | +::: zone-end |
| 33 | +## Next steps |
42 | 34 |
|
43 |
| -For a more detailed code sample on how to create a UI display to show the local and current incominng audio level please see [here](https://github.com/Azure-Samples/communication-services-web-calling-tutorial/blob/2a3548dd4446fa2e06f5f5b2c2096174500397c9/Project/src/MakeCall/VolumeVisualizer.js). |
| 35 | +For more information, see the following article: |
44 | 36 |
|
| 37 | +- Learn more about [Calling SDK capabilities](./getting-started-with-calling.md) |
0 commit comments