Skip to content

Commit 85a9cde

Browse files
authored
Merge pull request #270246 from chengyuanlai-msft/patch-4
Add ACS Calling Native SDK volume indicator quickstart
2 parents a933a79 + 921aed6 commit 85a9cde

File tree

5 files changed

+170
-29
lines changed

5 files changed

+170
-29
lines changed
Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,37 @@
11
---
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
34
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.
56
author: sloanster
6-
7-
ms.author: micahvivion
8-
ms.date: 1/18/2023
7+
services: azure-communication-services
8+
ms.date: 03/26/2024
99
ms.topic: quickstart
1010
ms.service: azure-communication-services
1111
ms.subservice: calling
12+
zone_pivot_groups: acs-plat-web-ios-android-windows
1213
ms.custom: mode-other
1314
---
1415

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
2117

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
2421

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
2725

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
3429

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
4234

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:
4436

37+
- Learn more about [Calling SDK capabilities](./getting-started-with-calling.md)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Quickstart - Add volume indicator to your Android calling app
3+
titleSuffix: An Azure Communication Services document
4+
description: In this quickstart, you'll learn how to check call volume within your calling app when using Azure Communication Services.
5+
author: sloanster
6+
7+
ms.author: chengyuanlai
8+
ms.date: 03/26/2024
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.subservice: calling
12+
---
13+
14+
[!INCLUDE [Public Preview](../../../../includes/public-preview-include-document.md)]
15+
16+
As a developer you can have control over checking microphone volume. This quickstart shows examples of how to accomplish it within the Azure Communication Services Calling SDK.
17+
18+
## Checking the local audio stream volume
19+
As a developer it can be nice to have the ability to check and display to end users the current local microphone volume level. Azure Communication Services calling API exposes this information using `getVolumeLevel`. The `getVolumeLevel` value is a float number ranging from 0 to 1 (with 0 noting zero audio detected, 100 as the max level detectable, -1 noting a failed operation).
20+
21+
### Example usage
22+
This example shows how to generate the volume level by accessing `getVolumeLevel` of the local audio stream.
23+
24+
```java
25+
//Get the volume of the local audio source
26+
OutgoingAudioStream stream = call.getActiveOutgoingAudioStream();
27+
try{
28+
float volume = stream.getVolumeLevel();
29+
}catch (Exception e) {
30+
e.printStackTrace();
31+
}
32+
```
33+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Quickstart - Add volume indicator to your iOS calling app
3+
titleSuffix: An Azure Communication Services document
4+
description: In this quickstart, you'll learn how to check call volume within your calling app when using Azure Communication Services.
5+
author: sloanster
6+
7+
ms.author: chengyuanlai
8+
ms.date: 03/26/2024
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.subservice: calling
12+
---
13+
14+
[!INCLUDE [Public Preview](../../../../includes/public-preview-include-document.md)]
15+
16+
As a developer you can have control over checking microphone volume. This quickstart shows examples of how to accomplish it within the Azure Communication Services Calling SDK.
17+
18+
## Checking the local audio stream volume
19+
As a developer it can be nice to have the ability to check and display to end users the current local microphone volume level. Azure Communication Services calling API exposes this information using `volumeLevel`. The `volumeLevel` value is a float number ranging from 0 to 1 (with 0 noting zero audio detected, 100 as the max level detectable, -1 noting a failed operation).
20+
21+
### Example usage
22+
This example shows how to generate the volume level by accessing `volumeLevel` of the local audio stream.
23+
24+
```swift
25+
//Get the volume of the local audio source
26+
if let volume = call?.activeOutgoingAudioStream.volumeLevel {
27+
print("Outgoing audio volume is %d", log:log, volume)
28+
} else {
29+
print("Get volume error")
30+
}
31+
```
32+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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: include
10+
ms.service: azure-communication-services
11+
ms.subservice: calling
12+
ms.custom: mode-other
13+
---
14+
15+
As a developer you can have control over checking microphone volume in JavaScript. This quickstart shows examples of how to accomplish it within the Azure Communication Services WebJS.
16+
17+
## Prerequisites
18+
>[!IMPORTANT]
19+
> 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.
20+
21+
## Checking the audio stream volume
22+
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.
23+
24+
### Example usage
25+
This example shows how to generate the volume level by accessing `getVolume` of the local audio stream and of the remote incoming audio stream.
26+
27+
```javascript
28+
//Get the volume of the local audio source
29+
const volumeIndicator = await new SDK.LocalAudioStream(deviceManager.selectedMicrophone).getVolume();
30+
volumeIndicator.on('levelChanged', ()=>{
31+
console.log(`Volume is ${volumeIndicator.level}`)
32+
})
33+
34+
//Get the volume level of the remote incoming audio source
35+
const remoteAudioStream = call.remoteAudioStreams[0];
36+
const volumeIndicator = await remoteAudioStream.getVolume();
37+
volumeIndicator.on('levelChanged', ()=>{
38+
console.log(`Volume is ${volumeIndicator.level}`)
39+
})
40+
```
41+
42+
For a more detailed code sample on how to create a UI display to show the local and current incoming audio level, see [here](https://github.com/Azure-Samples/communication-services-web-calling-tutorial/blob/2a3548dd4446fa2e06f5f5b2c2096174500397c9/Project/src/MakeCall/VolumeVisualizer.js).
43+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Quickstart - Add volume indicator to your Windows calling app
3+
titleSuffix: An Azure Communication Services document
4+
description: In this quickstart, you'll learn how to check call volume within your calling app when using Azure Communication Services.
5+
author: sloanster
6+
7+
ms.author: chengyuanlai
8+
ms.date: 03/26/2024
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.subservice: calling
12+
---
13+
14+
[!INCLUDE [Public Preview](../../../../includes/public-preview-include-document.md)]
15+
16+
As a developer you can have control over checking microphone volume. This quickstart shows examples of how to accomplish it within the Azure Communication Services Calling SDK.
17+
18+
## Checking the local audio stream volume
19+
As a developer it can be nice to have the ability to check and display to end users the current local microphone volume level. Azure Communication Services calling API exposes this information using `VolumeLevel`. The `VolumeLevel` value is a float number ranging from 0 to 1 (with 0 noting zero audio detected, 100 as the max level detectable, -1 noting a failed operation).
20+
21+
### Example usage
22+
This example shows how to generate the volume level by accessing `VolumeLevel` of the local audio stream.
23+
24+
```csharp
25+
//Get the volume of the local audio source
26+
OutgoingAudioStream stream = call.ActiveOutgoingAudioStream;
27+
28+
if (stream != null)
29+
{
30+
try
31+
{
32+
Trace.WriteLine("Current volume is: " + stream.VolumeLevel.ToString());
33+
}
34+
catch (Exception ex)
35+
{
36+
Trace.WriteLine("Failed to get volume for this audio stream");
37+
}
38+
}
39+
```
40+

0 commit comments

Comments
 (0)