Skip to content

Commit

Permalink
Merge pull request #680 from AgoraIO/isFeatureAvailableElectron
Browse files Browse the repository at this point in the history
Add advanced API query for electron
  • Loading branch information
Kishan-Dhakan authored Oct 20, 2023
2 parents 629ed55 + c1c7b6b commit e9f84e0
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ To enable and change virtual backgrounds, you add a button to the user interface

```javascript
VirtualBackgroundSource,
SegmentationProperty
SegmentationProperty,
FeatureType
```

1. **Define variables to keep track of the virtual background state**
Expand All @@ -31,11 +32,21 @@ To enable and change virtual backgrounds, you add a button to the user interface

2. **Enable virtual background**

When a user presses the button, you call `enableVirtualBackground` to enable background blur. When the user presses the button again, you change the virtual background to a solid color. On the next button press, you set a `.jpg` or `.png` image as the virtual background. To specify these background effects, you configure `virtualBackgroundSource` and `SegmentationProperty`. To do this, in `preload.js`, add the following method before `document.getElementById("join").onclick = async function ()`:
When a user presses the button, you check if the user's device supports the virtual background feature. If `isFeatureAvailableOnDevice` returns true, you call `enableVirtualBackground` to enable background blur.
- When the user presses the button again, you change the virtual background to a solid color.
- On the next button press, you set a `.jpg` or `.png` image as the virtual background.

To specify these background effects, you configure `virtualBackgroundSource` and `SegmentationProperty`. To do this, in `preload.js`, add the following method before `document.getElementById("join").onclick = async function ()`:

```javascript
document.getElementById("virtualBackground").onclick = async function ()
{
if (
!agoraEngine.isFeatureAvailableOnDevice(FeatureType.VideoVirtualBackground)
) {
console.log("Your device does not support virtual background");
return;
}
counter++;
if (counter > 3)
{
Expand Down Expand Up @@ -82,4 +93,4 @@ To enable and change virtual backgrounds, you add a button to the user interface
virtualBackgroundSource, segmentationProperty);
}
```
</PlatformWrapper>
</PlatformWrapper>

0 comments on commit e9f84e0

Please sign in to comment.