Silent fail when passing videoElement to startVideo

With the new update, the startVideo call fails when passing in a canvas element in the startVideo call.

Example:

let startVideoOptions = {
  videoElement: element, // canvas OR video element reference
  hd: true,
  mirrored: true,
  virtualBackground,
  cameraId
};

if (stream.isRenderSelfViewWithVideoElement()) {
  await stream.startVideo(startVideoOptions);
} else {
  await stream.startVideo(startVideoOptions); // This promise never resolves because we're passing in a `videoElement` property
  await stream.renderVideo(element, client.getCurrentUserInfo().userId, 640, 360, 0, 0, VideoQuality.Video_720P);
}

Previously, this wasn’t the case. So, updating to the new version broke the application.
The fix for this is to avoid passing in the videoElement when stream.isRenderSelfViewWithVideoElement() is false.

Perhaps the VideoSDK should provide some kind of error/warning for this situation.

Hey @miguel2

Thanks for your feedback.

We will improve the behavior in the next version.

P.S.
Starting from Video SDK Web 1.10.5, there’s no need to consider whether a videoElement is required when calling stream.startVideo method. We’ve improved the timing for this decision, allowing it to be made when calling stream.renderVideo instead, and the parameter also supports passing in a video tag.

Thanks
Vic

Not sure if understand what you mean, sorry.

The docs mention this:

if (stream.isRenderSelfViewWithVideoElement()) {
  await stream.startVideo({
    videoElement: document.querySelector('#my-self-view-video')
  })
  // video successfully started and rendered
} else {
  await stream.startVideo()
  await stream.renderVideo(
    document.querySelector('#my-self-view-canvas'),
    client.getCurrentUserInfo().userId, 1920, 1080, 0, 0, 3)
  // video successfully started and rendered
}

What would be the new way to do this?

Hey @miguel2

The new way would be as follows:

// start video
await stream.startVideo();


// render self view
const targetElement = stream.isRenderSelfViewWithVideoElement()
  ? document.querySelector("#my-self-view-video")
  : document.querySelector("#my-self-view-canvas");

await stream.renderVideo(
  targetElement,
  client.getCurrentUserInfo().userId,
  1920,
  1080,
  0,
  0,
  3
);

Thanks
Vic

Thank you.

In the docs for the videoElement option in startVideo, we can read:

Video element. Only used in Android platform or non-SharedArrayBuffer Chromium-like browsers.

Is this not the case anymore and we can safely only pass in the element to the renderVideo method?

Hey @miguel2

Yes, we will update the documentation shortly.

Thanks
Vic

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.