# Host is unable to close user’s cameras

**URL:** <https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802>\
**Category:** Web\
**Tags:** video-sdk\
**Created:** [October 9, 2024, 12:50pm UTC](https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802 "2024-10-09T12:50:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev\_lxpead](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dev_lxpead/32/63797_2.png) [@dev\_lxpead](https://devforum.zoom.us/u/dev_lxpead)\
**Post date:** [October 9, 2024, 12:50pm UTC](https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802/1 "2024-10-09T12:50:48Z")

</div>

All integrations were made following the Zoom Video SDK documentation.  
I’m having some unsolved issues in the documentation.

When the user opens the camera for the first time, hsot can close the camera, however, if the user activates the host again, it can no longer close it.  
Below is the excerpt cited in the documentation I used:

```auto
stream.stopVideo().then(() => {
  stream.detachVideo(USER_ID)
})

```

In my code I created the following function that receives the stream and the ID of the user I want to stop the camera from:

```auto
const stopVideo = async (mediaStream, userId) => {
        setHiddenCamera(true)
        setVideoStarted(false);
        mediaStream.stopVideo().then(() => {
            mediaStream.detachVideo(userId)
        })
}

```

After the user opens the camera again, whenever I try to call the stopVideo function an error occurs in the console (camera is closed).  
I would like to know if the host really does not have this control over the user’s camera or if there is something wrong in my implementation.

Below is more information about the versions and system I am using:  
Video SDK version: 1.12.5  
React version: 18  
Next JS version: 14.2.2  
OS: Windows 11  
Browser: Google Chrome  
Browser Version 129.0.6668.70 (Official Build) (64 bits)

---

<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:** [October 10, 2024, 2:51am UTC](https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802/2 "2024-10-10T02:51:18Z")

</div>

Hey @dev_lxpead

Thanks for your feedback.

Currently, the host cannot directly turn off other users’ cameras in a meeting. Calling `mediaStream.stopVideo()` will only turn off the camera for the current user. If you want to implement a way to turn off someone else’s camera, you can use the command channel. Here’s a simple example:

```javascript
const cmdClient = client.getCommandClient();
const stopVideoCmd = { cmd: "STOP_VIDEO" };
/**
 * Host side
 */

cmdClient.send(JSON.stringify(stopVideoCmd), USER_ID);

/**
 * User side
 */

client.on("command-channel-message", (payload) => {
  const { text } = payload;
  const cmd = JSON.parse(text || "{}");
  if (cmd.cmd === "STOP_VIDEO") {
    mediaStream.stopVideo();
  }
});

```

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![dev\_lxpead](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dev_lxpead/32/63797_2.png) [@dev\_lxpead](https://devforum.zoom.us/u/dev_lxpead)\
**Post date:** [October 10, 2024, 12:30pm UTC](https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802/3 "2024-10-10T12:30:44Z")

</div>

Hi @vic.yang !  
Thank you very much for your feedback, I will implement it this way and get back to you with feedback.

---

<div class="post-metadata">

**Author:** ![dev\_lxpead](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dev_lxpead/32/63797_2.png) [@dev\_lxpead](https://devforum.zoom.us/u/dev_lxpead)\
**Post date:** [October 25, 2024, 10:17pm UTC](https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802/4 "2024-10-25T22:17:08Z")

</div>

Hello @vic.yang !  
The solution suggested worked perfectly, thank you very much!

---

<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:** [November 25, 2024, 8:18am UTC](https://devforum.zoom.us/t/host-is-unable-to-close-user-s-cameras/118802/5 "2024-11-25T08:18:06Z")

</div>

Closed on November 25, 2024, 8:18am UTC

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