# How to Keep the Camera Focused on One User During a Call?

**URL:** <https://devforum.zoom.us/t/how-to-keep-the-camera-focused-on-one-user-during-a-call/123929>\
**Category:** Web\
**Tags:** video-sdk\
**Created:** [January 5, 2025, 6:34am UTC](https://devforum.zoom.us/t/how-to-keep-the-camera-focused-on-one-user-during-a-call/123929 "2025-01-05T06:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Humair](https://avatars.discourse-cdn.com/v4/letter/h/aca169/32.png) [@Humair](https://devforum.zoom.us/u/Humair)\
**Post date:** [January 5, 2025, 6:34am UTC](https://devforum.zoom.us/t/how-to-keep-the-camera-focused-on-one-user-during-a-call/123929/1 "2025-01-05T06:34:10Z")

</div>

I want to keep the camera fixed on a user and prevent the main screen from switching while they are speaking. Do you have any suggestions for achieving this?  
Any anyone help me? What do I do with my Zoom chatter?

---

<div class="post-metadata">

**Author:** ![ekaansh.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ekaansh.zoom/32/55004_2.png) [@ekaansh.zoom](https://devforum.zoom.us/u/ekaansh.zoom)\
**Post date:** [January 7, 2025, 10:51am UTC](https://devforum.zoom.us/t/how-to-keep-the-camera-focused-on-one-user-during-a-call/123929/2 "2025-01-07T10:51:26Z")

</div>

If you’re using the Video SDK. You can render the specific user based on their UID. You can skip the logic for other users. Here’s some code:

```js
import ZoomVideo, { VideoPlayer, VideoQuality } from "@zoom/videosdk";
import "./style.css";

// You should sign your JWT with a backend service in a production use-case
const sdkKey = ""

const videoContainer = document.querySelector('video-player-container') as HTMLElement;
const topic = "Test";
const role = 1;
const username = `User-${String(new Date().getTime()).slice(6)}`;
const client = ZoomVideo.createClient();
await client.init("en-US", "Global", { patchJsMedia: true });

const startCall = async () => {
  // generate a token to join the session - in production this will be done by your backend
  const token = fetch("");
  client.on("peer-video-state-change", renderVideo);
  await client.join(topic, token, username);
  const mediaStream = client.getMediaStream();
  await mediaStream.startAudio();
  await mediaStream.startVideo();
  // render the video of the current user
  await renderVideo({ action: 'Start', userId: client.getCurrentUserInfo().userId });
};

const renderVideo = async (event: { action: "Start" | "Stop"; userId: number; }) => {
   if ( userId == "YOUR_DESIRED_UID_HERE") {
    const mediaStream = client.getMediaStream();
    if (event.action === 'Stop') {
      const element = await mediaStream.detachVideo(event.userId);
      Array.isArray(element) ? element.forEach((el) => el.remove()) : element.remove();
    } else {
      const userVideo = await mediaStream.attachVideo(event.userId, VideoQuality.Video_360P);
      videoContainer.appendChild(userVideo as VideoPlayer);
    }
  } else {
  // dont render
}
};

const leaveCall = async () => {
  const mediaStream = client.getMediaStream();
  for (const user of client.getAllUser()) {
    const element = await mediaStream.detachVideo(user.userId);
    Array.isArray(element) ? element.forEach((el) => el.remove()) : element.remove();
  }
  client.off("peer-video-state-change", renderVideo);
  await client.leave();
}

// UI Logic
const startBtn = document.querySelector("#start-btn") as HTMLButtonElement;
const stopBtn = document.querySelector("#stop-btn") as HTMLButtonElement;

startBtn.addEventListener("click", async () => {
  if (!sdkKey || !sdkSecret) {
    alert("Please enter SDK Key and SDK Secret in the .env file");
    return;
  }
  startBtn.innerHTML = "Connecting...";
  startBtn.disabled = true;
  await startCall();
  startBtn.innerHTML = "Connected";
  startBtn.style.display = "none";
  stopBtn.style.display = "block";
});

stopBtn.addEventListener("click", async () => {
  await leaveCall();
  stopBtn.style.display = "none";
  startBtn.style.display = "block";
  startBtn.innerHTML = "Join";
  startBtn.disabled = false;
});

```

---

<div class="post-metadata">

**Author:** ![Humair](https://avatars.discourse-cdn.com/v4/letter/h/aca169/32.png) [@Humair](https://devforum.zoom.us/u/Humair)\
**Post date:** [January 13, 2025, 5:53pm UTC](https://devforum.zoom.us/t/how-to-keep-the-camera-focused-on-one-user-during-a-call/123929/4 "2025-01-13T17:53:01Z")

</div>

I appreciate your assistance. Thank you!

---

<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:** [February 13, 2025, 9:14pm UTC](https://devforum.zoom.us/t/how-to-keep-the-camera-focused-on-one-user-during-a-call/123929/6 "2025-02-13T21:14:14Z")

</div>

Closed on February 13, 2025, 9:14pm UTC

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