# Silent fail when passing videoElement to startVideo

**URL:** <https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960>\
**Category:** Web\
**Created:** [February 15, 2024, 11:50pm UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960 "2024-02-15T23:50:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguel2](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/miguel2/32/55570_2.png) [@miguel2](https://devforum.zoom.us/u/miguel2)\
**Post date:** [February 15, 2024, 11:50pm UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/1 "2024-02-15T23:50:56Z")

</div>

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

Example:

```js
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.

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [February 19, 2024, 9:16am UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/2 "2024-02-19T09:16:03Z")

</div>

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.

> **[Stream | Zoom Video SDK for Web - 1.10.7](https://marketplacefront.zoom.us/sdk/custom/web/modules/Stream.html#renderVideo)**
>
> Documentation for Zoom Video SDK for Web - 1.10.7

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![miguel2](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/miguel2/32/55570_2.png) [@miguel2](https://devforum.zoom.us/u/miguel2)\
**Post date:** [February 20, 2024, 12:59am UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/3 "2024-02-20T00:59:20Z")

</div>

Not sure if understand what you mean, sorry.

The docs mention this:

```js
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?

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [February 20, 2024, 1:31am UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/4 "2024-02-20T01:31:47Z")

</div>

Hey @miguel2

The new way would be as follows:

```javascript
// 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

---

<div class="post-metadata">

**Author:** ![miguel2](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/miguel2/32/55570_2.png) [@miguel2](https://devforum.zoom.us/u/miguel2)\
**Post date:** [February 20, 2024, 2:16pm UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/5 "2024-02-20T14:16:09Z")

</div>

Thank you.

In the [docs for the `videoElement` option in startVideo](https://marketplacefront.zoom.us/sdk/custom/web/interfaces/CaptureVideoOption.html#videoElement), 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?

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [February 21, 2024, 1:38am UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/6 "2024-02-21T01:38:12Z")

</div>

Hey @miguel2

Yes, we will update the documentation shortly.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [March 22, 2024, 11:38am UTC](https://devforum.zoom.us/t/silent-fail-when-passing-videoelement-to-startvideo/103960/7 "2024-03-22T11:38:36Z")

</div>

Closed on March 22, 2024, 11:38am UTC

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