-
Notifications
You must be signed in to change notification settings - Fork 28
Virtual Background
adamrangs edited this page Aug 8, 2022
·
1 revision
Virtual Background lets the user use a custom image as the background for the video. Users can also use the blur effect as the background. Users can set 3 types of virtual background None, Blur, and Custom. Example of same are given below:
This is equivalent to disable virtual background.
This blurs the background as shown in the image below.
This lets the user use their own custom image as background.
- First check whether the device supports virtual background by using
isVirtualBackgroundSupported: Bool
, if this API returns true you can go ahead and use the feature. - To fetch all the virtual backgrounds available use
func fetchVirtualBackgrounds(completionHandler: @escaping (_ result: Result<[VirtualBackground]>) -> Void)
API which will return array of VirtualBackground array. None and Blur type VirtualBackground is available by default. - For uploading a custom background use
func addVirtualBackground(image: LocalFile, completionHandler: @escaping (_ result: Result<VirtualBackground>) -> Void)
API which will give you the VirtualBackground on completion. - For setting the virtual background use
func applyVirtualBackground(background: VirtualBackground, mode: VirtualBackgroundMode, completionHandler: @escaping (_ result: Result<Bool>) -> Void)
specify the mode among preview or call as per requirement. - To manage the virtual backgrounds use
func removeVirtualBackground(background: VirtualBackground, completionHandler: @escaping (_ result: Result<Bool>) -> Void)
API to delete a specific Custom VirtualBackground. None and Blur type cannot be deleted. - You can modify the limit of custom virtual background supported by setting
virtualBackgroundLimit: Int
. The default limit is 3.
- For adding 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
Call.onCpuHitThreshold: (() -> Void)?
will be fired, you can ask the user to disable the virtual background once this event triggers.