Skip to content

Commit

Permalink
Added volume indicator details
Browse files Browse the repository at this point in the history
  • Loading branch information
pothinenikarthik-plivo committed Feb 13, 2020
1 parent 4b8c7be commit e860ae5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ This is where we initialise a new Plivo object by passing `options` as `plivoWeb
plivoWebSdk.client.on('onMediaPermission', onMediaPermission);
plivoWebSdk.client.on('mediaMetrics',mediaMetrics);
plivoWebSdk.client.on('audioDeviceChange',audioDeviceChange);
plivoWebSdk.client.on('onConnectionChange', onConnectionChange);
plivoWebSdk.client.on('volume', volume);
plivoWebSdk.client.setRingTone(true);
plivoWebSdk.client.setRingToneBack(true);
console.log('initPhone ready!')
Expand Down Expand Up @@ -425,4 +427,18 @@ $('#sendFeedback').click(function(){
plivoWebSdk.client.sendQualityFeedback(lastCallid,score,comment);
customAlert('Quality feedback ',lastCallid);
});
```
```

### Real-time volume indicator on UI
Display user real-time volume of mic and speaker.
'volume' event handler will be invoked 60 times per second. The handler receives inputVolume and outputVolume as percentages of maximum volume represented by a floating point number between 0.0 and 1.0, inclusive. This value represents a range of relative decibel values between -100dB and -30dB.
![plivo-websdk-2.0-example](img/volume.png)

```js
function volume(audioStats){
inputVolume = audioStats.inputVolume;
outputVolume = audioStats.outputVolume;
inputVolumeBar.style.width = Math.floor(inputVolume * 400) + ‘px’;
outputVolumeBar.style.width = Math.floor(outputVolume * 400) + ‘px’;
}
```
Binary file added img/volume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions webApp-plivo/public/js/customclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ function tokenGenFunc(){
}


function onVolume(audioStats){
function volume(audioStats){
inputVolume = audioStats.inputVolume;
outputVolume = audioStats.outputVolume;
inputVolumeBar.style.width = Math.floor(inputVolume * 400) + 'px';
Expand Down Expand Up @@ -1043,7 +1043,7 @@ function initPhone(username, password){
plivoWebSdk.client.on('audioDeviceChange',audioDeviceChange);
plivoWebSdk.client.on('onPermissionNeeded', onPermissionNeeded);
plivoWebSdk.client.on('onConnectionChange', onConnectionChange); // To show connection change events
plivoWebSdk.client.on('volume', onVolume);
plivoWebSdk.client.on('volume', volume);

// Methods
plivoWebSdk.client.setRingTone(true);
Expand Down

0 comments on commit e860ae5

Please sign in to comment.