Use virtual backgrounds

View as Markdown

Use isSupportVirtualBG in MobileRTCMeetingService to determine whether the device supports virtual backgrounds, then use MobileRTCMeetingService to enable them. You can also check to see if the smart virtual background - virtual backgrounds without the need for a green screen - are supported. Both images and video are supported for virtual background.

if let vbSetting = ZoomSDK.shared().getSettingService()?.getVirtualBGSetting() {
    /*
     Normal virtual background: virtual background used with a green screen.
     Smart virtual Background: virtual backgrounds without the need for a green screen, but it has certain system performance requirements based on https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0060007
     */

    if vbSetting.isSupportVirtualBG() {
        // Normal virtual background image is supported
    }

    if vbSetting.isDeviceSupportSmartVirtualBG() {
        // Smart virtual background image is supported
    }

    if vbSetting.isDeviceSupportGreenVirtualBackgroundVideo() {
        // Normal virtual background video is supported
    }

    if vbSetting.isDeviceSupportSmartVirtualBackgroundVideo() {
        // Smart virtual background video is supported
    }
}

If the device supports virtual backgrounds, use meetingService to list, add, remove, and set virtual backgrounds.

// To list available virtual background
if let listOfVirtualBG = vbSetting.getBGItemList() as? [ZoomSDKVirtualBGImageInfo] {
    // This list will contained a NONE, BLUR or other image/video (self added).
    for vb in listOfVirtualBG {
        vb.isAllowDelete()
        vb.getImageFilePath()
        vb.getImageName()
        vb.isSelected()
        vb.isVideo()
    }
}

// To add virtual background to list, first check for permission.
if vbSetting.isAllowAddNewVBItem() {
    let error = vbSetting.addBGImage(<#T##filePath: String##String#>)
}

/*
 To remove a specific virtual background from the list, first check for permission.
 Note: You cannot remove NONE and BLUR type.
 */
if vbSetting.isAllowRemoveVBItem() {
    let error = vbSetting.removeBGItem(<#T##virtualBGImageInfo: ZoomSDKVirtualBGImageInfo##ZoomSDKVirtualBGImageInfo#>)
}

// To set a specific virtual background
vbSetting.useBGItem(<#T##item: ZoomSDKVirtualBGImageInfo##ZoomSDKVirtualBGImageInfo#>)

Users can preview their virtual background.

let yourPreviewView:NSView = NSView() // Get your NSView
let previewVideoItem = ZoomSDKPreViewVideoElement(frame: yourPreviewView.frame)
var videoElement: ZoomSDKVideoElement? = previewVideoItem
let videoContainer = ZoomSDK.shared().getMeetingService()?.getVideoContainer()
videoContainer?.createVideoElement(&videoElement)
yourPreviewView.addSubview(previewVideoItem.getVideoView())
previewVideoItem.startPreview(true)

Users can also have green screen support for virtual backgrounds. When green screen is not being used, this means that the smart virtual background are turned on. In order for smart virtual background to be turned on, the macOS system must fulfill certain requirement that can be found in this link.

vbSetting.isUsingGreenScreenOn()
vbSetting.setUsingGreenScreen(true) // or false