enableVirtualBackground method

Future<int?> enableVirtualBackground(
  1. string modelPath,
  2. VirtualBackgroundSource source
)

@detail api @author zhushufan.ref @brief Sets the original background to a specified image or a solid color. @param backgroundStickerRes The absolute path of virtual background effects. @param source Virtual background source. See VirtualBackgroundSource{@link #VirtualBackgroundSource}. @return - 0: Success. - –1000: The Effects SDK is not integrated. - –1001: This API is unavailable for your Effects SDK. - –1002: Your Effects SDK's version is incompatible. - < 0: Other error. See error code table for specific instructions. @note - You must call initCVResource{@link #IVideoEffect#initCVResource} before calling this API. - Call disableVirtualBackground{@link #IVideoEffect#disableVirtualBackground} to turn off the virtual background.

Implementation

Future<int?> enableVirtualBackground(
    string modelPath, VirtualBackgroundSource source) async {
  $a() => ($instance as $p_a.IVideoEffect).enableVirtualBackground(
      modelPath, unpackObject<$p_a.VirtualBackgroundSource>(source));
  $i() => ($instance as $p_i.ByteRTCVideoEffect).enableVirtualBackground(
      modelPath, unpackObject<$p_i.ByteRTCVirtualBackgroundSource>(source));

  if (Platform.isAndroid) {
    return $a();
  } else if (Platform.isIOS) {
    return $i();
  } else {
    throw UnsupportedError(
        'Not Support Platform ${Platform.operatingSystem}');
  }
}