Skip to content

Commit 9d56e3b

Browse files
authored
Update get-started-volume-indicator.md
1 parent 13f6b70 commit 9d56e3b

File tree

1 file changed

+11
-54
lines changed

1 file changed

+11
-54
lines changed
Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Quickstart - Add volume indicator to your Web calling app
33
titleSuffix: An Azure Communication Services quickstart
4-
description: In this quickstart, you'll learn how to add raw media access calling capabilities to your app using Azure Communication Services.
4+
description: In this quickstart, you'll learn how to check call volume within you Web app when using Azure Communication Services.
55
author: sloanster
66

77
ms.author: micahvivion
@@ -12,65 +12,29 @@ ms.subservice: calling
1212
ms.custom: mode-other
1313
---
1414

15-
As a developer you can have control over checking microphone volume in Javascript
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 do this in the ACS WebJS.
1617

1718
## Prerequisites
18-
[!INCLUDE [Public Preview](../../../../includes/public-preview-include-document.md)]
19+
[!INCLUDE [Public Preview](../../../includes/public-preview-include-document.md)]
1920

2021
>[!IMPORTANT]
21-
> 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 version or newer when trying this quickstart.
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.
2223
23-
## Checking the audio stream olume
24-
### Description
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 200ms to get near realtime value of volume.
2526

26-
As a developer it can be nice to have the ability to check the microphone volume in Javascript. This quickstart shows examples of how to do this in ACS WebJS.
27+
### Example usage
28+
Sample code to get volume of selected microphone. This example shows how to generate the volume level by accessing `getVolume`.
2729

28-
#### Architecture
29-
##### Pre/Post Call
30-
ACS Already has raw audio stream access api built over TsCall on Device Manager this can be used to expose audio gain for precall/incall Microphone volume.
3130
```javascript
32-
export interface LocalAudioStream {
33-
getMediaStreamTrack(): Promise<MediaStreamTrack>;
34-
switchSource(source: AudioDeviceInfo | MediaStreamTrack): Promise<void>;
35-
dispose();
36-
}
37-
export interface RemoteAudioStream {
38-
getMediaStreamTrack(): Promise<MediaStreamTrack>;
39-
}
40-
```
41-
ACS will expose another API on local and remote audio streams to get Microphone volume built over Raw Audio access API, to get Volume (gain) of selected Microphone
42-
```javascript
43-
export interface LocalAudioStream {
44-
getVolume(): Promise<Volume>;
45-
...
46-
}
47-
48-
export interface RemoteAudioStream {
49-
getVolume(): Promise<Volume>;
50-
...
51-
}
52-
53-
export interface Volume extends Disposable{
54-
off(event: 'levelChanged', listener: PropertyChangedEvent): void;
55-
on(event: 'levelChanged', listener: PropertyChangedEvent): void;
56-
readonly level: number;
57-
}
58-
```
59-
The volume is a number ranging from 0 to 100
60-
It's sampled every 200ms to get near realtime value of volume
61-
#### Example usage
62-
Sample code to get volume of selected microphone
63-
64-
need call getVolume on audioSourceChanged for local audio stream
65-
66-
```javascript
67-
31+
//Get the vaolume of the local audio source
6832
const volumeIndicator = await new SDK.LocalAudioStream(deviceManager.selectedMicrophone).getVolume();
6933
volumeIndicator.on('levelChanged', ()=>{
7034
console.log(`Volume is ${volumeIndicator.level}`)
7135
})
7236

73-
37+
//Get the volume level of the remote incoming audio source
7438
const remoteAudioStream = call.remoteAudioStreams[0];
7539
const volumeIndicator = await remoteAudioStream.getVolume();
7640
volumeIndicator.on('levelChanged', ()=>{
@@ -79,10 +43,3 @@ volumeIndicator.on('levelChanged', ()=>{
7943

8044
```
8145

82-
#### Telemetry for localAudioStream
83-
best effort to send telemetry, from localAudioStream
84-
if call client is not initialized before LocalAudioStream, no telemetry will be sent
85-
86-
For MediaStreamTrack telemetry only from the first created call client will be sent
87-
cc1, new local stream ... everything works fine
88-
cc1, new local stream gets latched to telemetry logger from cc1, cc2, new local stream will not send data

0 commit comments

Comments
 (0)