-
Notifications
You must be signed in to change notification settings - Fork 31
Virtual Background
Virtual Background lets the user use a custom background for the video. Users can set 3 types of virtual background None, Blur, and Custom. Examples of the same are given below:
This is a default virtual background type. Setting this type removes the custom/blur background. This is equivalent to disabling virtual background.

This blurs the background as shown in the image below. To remove this background, you need to set VirtualBackgroundType.NONE.

This lets the user use their own custom image as background. To remove this background, you need to set VirtualBackgroundType.NONE.

-
To check if the device supports virtual background
val isSupported: Boolean = webex.phone.isVirtualBackgroundSupported()
-
To fetch all the virtual backgrounds available
webex.phone.fetchVirtualBackgrounds( CompletionHandler { result -> if (result.isSuccessful) { val data: List<VirtualBackground>? = result.data //display the background } else { Log.d(tag, "error: ${result.error?.message}") } })
This API provides the List of Virtual Backgrounds. None and Blur type VirtualBackground is available by default.
-
For uploading a virtual background (Max 1280x720)
val thumbnailFile = FileUtils.getFileFromResource(this, "nature-thumb") val file = FileUtils.getFileFromResource(this, "nature") val thumbnail = LocalFile.Thumbnail(thumbnailFile, null, 64, 64) val imgFile = LocalFile(file, null, thumbnail, null) webex.phone.addVirtualBackground(imgFile, CompletionHandler { result -> if (result.isSuccessful) { val data: VirtualBackground? = result.data //handle the success response } else { Log.d(tag, "error: ${result.error?.message}") } })
-
To apply the virtual background
//Specify the mode PREVIEW or CALL as per requirement. val mode = Phone.VirtualBackgroundMode.PREVIEW // Phone.VirtualBackgroundMode.CALL webex.phone.applyVirtualBackground(virtualBackgroundItem, mode, CompletionHandler { result -> if (result.isSuccessful) { val data: Boolean? = result.data //handle the success response } else { Log.d(tag, "error: ${result.error?.message}") } })
-
To remove the virtual backgrounds
webex.phone.removeVirtualBackground(background, CompletionHandler { result -> if (result.isSuccessful) { val data: Boolean? = result.data //handle the delete response } else { Log.d(tag, "error: ${result.error?.message}") } })
This API can delete a specific Custom VirtualBackground. None and Blur type cannot be deleted.
-
You can modify the limit of custom virtual background supported by the setting. The default limit is 3.
webex.phone.setMaxVirtualBackgroundItems(limit)
-
To retrieve the limit
val limit: Int = webex.phone.getMaxVirtualBackgroundItems()
- Custom background image types supported are JPG and PNG.
- SDK will resize uploaded image to 1280x720, if the image size will be greater than 1280x720 to avoid CPU overhead.
- Storage of application will be increased based on the images uploaded for virtual background
- Virtual Background uses lots of CPU, once reached threshold limit
CallObserver.onCpuHitThreshold
will be fired. It is recommended to disable the virtual background feature.