# Remote participant video player not working

**URL:** <https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017>\
**Category:** Twilio Migration\
**Created:** [March 4, 2024, 4:16pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017 "2024-03-04T16:16:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 4, 2024, 4:16pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/1 "2024-03-04T16:16:23Z")

</div>

I’m migrating from Twilio to Zoom Video SDK and I’m having a problem rendering the videos for remote participants using the code provided in the documentation.  
Here is what I’m doing:

```auto
zoomClient.on("peer-video-state-change", (payload) => {
    const mediaStream = zoomClient.getMediaStream();
    if (payload.action === "Start") {
        mediaStream.attachVideo(payload.userId, 3).then((userVideo) => {
            const videoPlayerContainer = document.querySelector("video-player-container") as Element;
            videoPlayerContainer.appendChild(userVideo as VideoPlayer);
        });
    } else if (payload.action === "Stop") {
        mediaStream.detachVideo(payload.userId);
    }
});

```

And then in the HTML I have the `<video-player-container></video-player-container>`.  
The participants are joining after the local participant and I don’t get any errors but the remote participant video just shows a black screen.  
Any ideas on what I might be doing wrong?

---

<div class="post-metadata">

**Author:** ![will.ezrine](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.ezrine/32/56999_2.png) [@will.ezrine](https://devforum.zoom.us/u/will.ezrine)\
**Post date:** [March 5, 2024, 1:27am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/2 "2024-03-05T01:27:41Z")

</div>

Hi Marcia,

Welcome!  
Can you provide me some more information as to where and how this event listener is being implemented? Do you know if it is successfully subscribed and if your code block is actually running?

Best,  
Will

---

<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:** [March 5, 2024, 6:13am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/3 "2024-03-05T06:13:45Z")

</div>

Hey @m.martins

Thanks for your feedback.

The element created by `mediaStream.attachVideo` may not have an initial size, which could be causing the black screen. Since it’s an HTML element, you can add a class to it and then set its width and height in CSS.

```css
  video-player-container{
    width: 1280px;
    height:720px;
  }

  .video-cell {
    aspect-ratio: 16/9;
    width: 300px;
  }

```

```javascript
mediaStream.attachVideo(payload.userId, 3).then((userVideo) => {
  const videoPlayerContainer = document.querySelector(
    "video-player-container"
  ) as Element;
  userVideo.classList.add("video-cell");
  videoPlayerContainer.appendChild(userVideo as VideoPlayer);
});

```

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 5, 2024, 10:52am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/4 "2024-03-05T10:52:35Z")

</div>

Hi Will, sure!

I’m using react and have created a hook to handle all things related to the zoom SDK. The event handler is being added this way:

```auto
useEffect(() => {
    if (zoomClient) {
        ...

        // update videos of remote participants
        zoomClient.on("peer-video-state-change", (payload) => {
            console.log("peer-video-state-change", payload);
            ...
        });

        return () => {
            ...
            zoomClient.off("peer-video-state-change")
        };
    }
}, [zoomClient]);

```

Then on the main component I just have this:

```auto
return (
    <div>
        <style>
            {`
                video-player-container {
                    width: 1280px;
                    height:720px;
                }

                .video-cell {
                    aspect-ratio: 16/9;
                    width: 300px;
                }
             `}
            </style>
           <video-player-container></video-player-container>
    </div>
)

```

I can tell the event handler is working since I added some console logs inside to render the returned video player and I can see it being added when I inspect the page. I’m also rendering the local user video using a similar approach and have no problems with that one:

```auto
const toggleVideo = async () => {
        const userId = zoomClient!.getCurrentUserInfo().userId;
        if (mediaStream!.isCapturingVideo()) {
            mediaStream!.stopVideo().then(() => mediaStream!.detachVideo(userId));
        } else {
            const videoPlayerContainer = document.querySelector("video-player-container");
            mediaStream!.startVideo().then(() => {
                mediaStream!.attachVideo(userId, VideoQuality.Video_720P).then((userVideo) => {
                    console.log("local user video player", userVideo);
                    userVideo.classList.add("video-cell");
                    videoPlayerContainer?.appendChild(userVideo as VideoPlayer);
                });
            });
        }
    };

```

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 5, 2024, 10:53am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/5 "2024-03-05T10:53:25Z")

</div>

Hi Vic!

Unfortunately this didn’t work, I still get a black video player for the remote participants.

---

<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:** [March 6, 2024, 2:04am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/6 "2024-03-06T02:04:38Z")

</div>

Hey @m.martins

Could you share the sessionId with issues to help us troubleshoot the problem?

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 6, 2024, 10:48am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/8 "2024-03-06T10:48:33Z")

</div>

Hi @vic.yang  
I’m not sure how to get the sessionID. Is it the zoomID I get after doing zoomClient.join()?

Thank you

---

<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:** [March 7, 2024, 1:49am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/9 "2024-03-07T01:49:22Z")

</div>

Hey @m.martins

You can obtain it from the Dashboard on the Video SDK Web portal page, or if your session is still ongoing, you can retrieve it using `client.getSessionInfo()`.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 7, 2024, 11:05am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/10 "2024-03-07T11:05:35Z")

</div>

Hi @vic.yang

The session ID is `ctAt5w3VSZubj8WPVtN+Eg==`. Thank you!

---

<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:** [March 8, 2024, 3:09am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/11 "2024-03-08T03:09:12Z")

</div>

Hey @m.martins

From the logs, we’ve noticed errors like `Cannot read properties of null (reading 'appendChild')`.

Could you please check the console for errors when the issue occurs?

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 11, 2024, 3:38pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/12 "2024-03-11T15:38:58Z")

</div>

Hi @vic.yang

The only error I’m seeing in the console at the moment is `Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.`

I’ve created a small test app where the problem is happening so it will be easier to share with you. I’m using Next.js

> **[GitHub - marciammart/zoom-test](https://github.com/marciammart/zoom-test)**
>
> Contribute to marciammart/zoom-test development by creating an account on GitHub.

Thank you!

---

<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:** [March 12, 2024, 1:59am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/13 "2024-03-12T01:59:30Z")

</div>

Hey @m.martins

Thank you for sharing the complete code example with us.

I’ve tested the code you provided and found some areas that need improvement. Below, I will list out some points for modification and explain the reasons.

- Style in [page.tsx](https://github.com/marciammart/zoom-test/blob/41d5c8445562878556a5ab7cfe6b9d74114b1114/src/app/page.tsx#L29) file

```css
    video-player {
       width: 400px;
       aspect-ratio:16/9;
     }

```

Since the video player does not have a default width and height, you need to set them manually. You previously set the width; the default height should be 9/16 of the width. Therefore, I added the `aspect-ratio` property to specify the height.

- Init option in [useZoomVideo.tsx](https://github.com/marciammart/zoom-test/blob/41d5c8445562878556a5ab7cfe6b9d74114b1114/src/hooks/useZoomVideo.tsx#L34) file

We recommend enabling `SharedArrayBuffer` to improve performance. You can refer to this doc.

> **[Video SDK - web - SharedArrayBuffer](https://developers.zoom.us/docs/video-sdk/web/sharedarraybuffer/)**
>
> The Zoom Developer Platform is an open platform that allows third-party developers to build applications and integrations upon Zoom’s video-first unified communications platform.

Since the test example doesn’t have these configurations, we recommend specifying the `enforceMultipleVideos` option as `true` when calling the `client.init` method.

This allows placing multiple `video-player` elements within the `video-player-container` even when `SharedArrayBuffer` is disabled. Otherwise, you would need one `video-player-container` per video.

Correspondingly,Video SDK Web provide the `stream.isSupportMultipleVideos()` method to detect whether this feature is supported.

Please feel free to reach out if you have any further questions or require additional assistance.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 18, 2024, 2:16pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/14 "2024-03-18T14:16:54Z")

</div>

Hi @vic.yang

The changes you recommended worked, but now I’m trying to attach the video to an existing video player, so I can add some styling to each participant’s video, and I’m having some issues.

I created a new component (`ParticipantContainer.tsx`) to render the participant video player and I’m running ` mediaStream.attachVideo(participant.userId, 3, videoPlayerRef.current)` when the `participant.bVideoOn` changes to true.  
This works for the local participant but not for the remote participant. I’ve also noticed that, even for the local participant, if I toggle the video on and off a few times, the video stops rendering and the node-id of the video player is changed to 0 instead of the userID.

Do you know what might be the problem? I updated the demo with all the new code.  
Thank you!

---

<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:** [March 20, 2024, 7:33am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/15 "2024-03-20T07:33:22Z")

</div>

Hey @m.martins

I made some changes in [ParticipantContainer.tsx](https://github.com/marciammart/zoom-test/blob/main/src/components/ParticipantContainer.tsx):

- On [line 24](https://github.com/marciammart/zoom-test/blob/795c46cc729cf26a0d5edc8b9c00f2bbe3bb0428/src/components/ParticipantContainer.tsx#L24), I removed the backgroundColor style setting. I moved the background setting to the `video-player-container` in [page.tsx](https://github.com/marciammart/zoom-test/blob/main/src/app/page.tsx). This is because within the `video-player-container`, we internally create a canvas, and the video rendering occurs on this canvas. If its descendant elements have a background color, it will block the display of the video.

- On lines 28-29, I removed the setting for the `node-id` and `media-type` attributes. These attributes will be handled within the Video SDK.

Please feel free to reach out if you have any further questions or require additional assistance.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [March 21, 2024, 3:14pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/16 "2024-03-21T15:14:09Z")

</div>

Thank you @vic.yang !

That fixed the render of the remote participant’s video but I’m still having problems when I toggle the video on and off a few times. If I toggle the video for the local participant, the video stops rendering and only shows a black video player, and if I toggle the remote participant, the video in the local participant’s page will show the last frame before the remote participant toggled the video off.  
I update the demo so you can see the problem.

---

<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:** [March 22, 2024, 2:39pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/17 "2024-03-22T14:39:10Z")

</div>

Hey @m.martins

After making a few code changes, it can now work:

- In [useZoomVideo.tsx](https://github.com/marciammart/zoom-test/blob/feb26524387ccc8f1f5be7f57d6424762beaf1e9/src/hooks/useZoomVideo.tsx#L53), within the `toggleVideo` method, I removed the call to `mediaStream.detachVideo` after `stopVideo`. Since both self-view and remote-view rendering use `ParticipantContainer`, there’s no need for an additional detach video here.

- In [`ParticipantContainer.tsx`](https://github.com/marciammart/zoom-test/blob/feb26524387ccc8f1f5be7f57d6424762beaf1e9/src/components/ParticipantContainer.tsx#L14), within the `useEffect`, you originally only handled the scenario where `bVideoOn` is `true`, but you missed the scenario where it’s `false`. Therefore, you need to call `detachVideo` to unbind the user from the video-player.

Please feel free to reach out if you have any further questions or require additional assistance.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![zunoor](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/zunoor/32/59382_2.png) [@zunoor](https://devforum.zoom.us/u/zunoor)\
**Post date:** [May 7, 2024, 10:51am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/18 "2024-05-07T10:51:02Z")

</div>

Yeah same Issue I am facing in Angular  
@m.martins I will be very thankful to you if you tell me the solution of this problem  
Only first (localParticipant) is being rendered  
And no other participants are rendered

---

<div class="post-metadata">

**Author:** ![zunoor](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/zunoor/32/59382_2.png) [@zunoor](https://devforum.zoom.us/u/zunoor)\
**Post date:** [May 7, 2024, 10:55am UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/19 "2024-05-07T10:55:05Z")

</div>

Hello @vic.yang  
I am facing the same issue as @m.martins is facing  
The video of only localParticipant is rendered and displayed on the screen  
As the new participants joins  
All the events are working fine and all the participants are managed perfectly!  
But their video is not Rendered  
Is there any issue with zoom SDK or I have to enable SharedArrayBuffer  
Thanks

---

<div class="post-metadata">

**Author:** ![m.martins](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/m.martins/32/50198_2.png) [@m.martins](https://devforum.zoom.us/u/m.martins)\
**Post date:** [May 7, 2024, 12:16pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/20 "2024-05-07T12:16:59Z")

</div>

Hi @zunoor  
Setting the `enforceMultipleVideos` to `true` in the client init function and removing the background from any component inside the `video-player-container` fixed the problem for me.

```auto
await zoomClient.init("en-US", "Global", { patchJsMedia: true, enforceMultipleVideos:true });

```

---

<div class="post-metadata">

**Author:** ![zunoor](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/zunoor/32/59382_2.png) [@zunoor](https://devforum.zoom.us/u/zunoor)\
**Post date:** [May 7, 2024, 12:45pm UTC](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017/21 "2024-05-07T12:45:58Z")

</div>

I did this already

```auto
 await this.zoomVideo.init('en-US', 'Global', { patchJsMedia: true, enforceMultipleVideos: true });

```

```auto
console.log(this.zoomSession.isSupportMultipleVideos();)

```

this returns true means multiple videos is enabled but still same issue

[Next page](https://devforum.zoom.us/t/remote-participant-video-player-not-working/105017.md?page=2)
