diff --git a/shared/extensions-marketplace/virtual-background/project-implementation/electron.mdx b/shared/extensions-marketplace/virtual-background/project-implementation/electron.mdx index ba204d255..66f0c2f95 100644 --- a/shared/extensions-marketplace/virtual-background/project-implementation/electron.mdx +++ b/shared/extensions-marketplace/virtual-background/project-implementation/electron.mdx @@ -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** @@ -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) { @@ -82,4 +93,4 @@ To enable and change virtual backgrounds, you add a button to the user interface virtualBackgroundSource, segmentationProperty); } ``` - \ No newline at end of file +