startVirtualBackground function

Future<MediaStream?> startVirtualBackground({
  1. required Uint8List backgroundImage,
  2. String? textureId,
})

Implementation

Future<MediaStream?> startVirtualBackground({
  required Uint8List backgroundImage,
  String? textureId,
}) async {
  try {
    final String base64String = base64Encode(backgroundImage);
    final JSObject? obj = enableVirtualBackground(base64String, textureId);

    if (obj == null) return null;

    final web.MediaStream jsStream = web.MediaStream(obj);
    return rtc.MediaStreamWeb(jsStream, 'local');
  } catch (error) {
    return null;
  }
}