Skip to content

Commit 2598264

Browse files
authored
Merge pull request #224316 from sloanster/patch-13
Create get-started-volume-indicator.md
2 parents 68e4677 + 6ba3f47 commit 2598264

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Quickstart - Add volume indicator to your Web calling app
3+
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+
author: sloanster
6+
7+
ms.author: micahvivion
8+
ms.date: 1/18/2023
9+
ms.topic: quickstart
10+
ms.service: azure-communication-services
11+
ms.subservice: calling
12+
ms.custom: mode-other
13+
---
14+
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 ACS WebJS.
17+
18+
## Prerequisites
19+
[!INCLUDE [Public Preview](../../includes/public-preview-include-document.md)]
20+
21+
>[!IMPORTANT]
22+
> The quick start examples here are available starting on the public preview version [1.9.1-beta.1](https://www.npmjs.com/package/@azure/communication-calling/v/1.9.1-beta.1) of the calling Web SDK. Make sure to use that SDK version or newer when trying this quickstart.
23+
24+
## Checking the audio stream volume
25+
As a developer it can be nice to have the ability to check and display to end users the current microphone volume. ACS 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 iss sampled every 200 ms to get near real time value of volume.
26+
27+
### Example usage
28+
Sample code to get volume of selected microphone. This example shows how to generate the volume level by accessing `getVolume`.
29+
30+
```javascript
31+
//Get the vaolume of the local audio source
32+
const volumeIndicator = await new SDK.LocalAudioStream(deviceManager.selectedMicrophone).getVolume();
33+
volumeIndicator.on('levelChanged', ()=>{
34+
console.log(`Volume is ${volumeIndicator.level}`)
35+
})
36+
37+
//Get the volume level of the remote incoming audio source
38+
const remoteAudioStream = call.remoteAudioStreams[0];
39+
const volumeIndicator = await remoteAudioStream.getVolume();
40+
volumeIndicator.on('levelChanged', ()=>{
41+
console.log(`Volume is ${volumeIndicator.level}`)
42+
})
43+
44+
```
45+

0 commit comments

Comments
 (0)