Host is unable to close user’s cameras

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:

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:

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)

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:

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

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

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