MY WEBCAM TEST GUIDE

Stop the camera with navigator.mediaDevices in Chrome

Stop camera capture in Chrome with MediaStreamTrack.stop(), keep webcam audio running when needed, and understand why a camera may remain active.

To stop camera capture in Chrome, call stop() on each video track in the MediaStream returned by navigator.mediaDevices.getUserMedia(). There is no navigator.mediaDevices.stopCamera() method. Stop only the video tracks if you want speech capture from the webcam microphone to continue.

Stop video while keeping the microphone running

Keep a reference to the stream when you start capture. The following example requests video and audio, then provides a function that stops only the camera tracks. Run it within an async function in a secure context; capture also requires the user's permission.

const stream = await navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true
});

function stopCamera() {
  stream.getVideoTracks().forEach((track) => track.stop());
}

// Call when the user chooses to stop the camera.
stopCamera();

Audio and video use separate tracks, even when the microphone and camera are built into the same webcam. Stopping the video tracks leaves the stream's audio tracks running. However, audio: true requests an available microphone; it does not guarantee selection of the microphone built into your webcam. Verify the selected audio input if that distinction matters for speech capture.

Stop both camera and microphone

To end both video and speech capture from this stream, stop every track:

stream.getTracks().forEach((track) => track.stop());

Why the camera may still appear active

Calling stop() ends that track. The physical camera can remain active if another live track, tab or application is using it. Check for other streams created by your page, including cloned tracks, if capture appears to continue.

Hiding a video element or setting its srcObject to null only changes playback; it does not stop the capture tracks. Setting a video track's enabled property to false disables its output while preserving the track for reuse. Use stop() when you intend to end that track.

Starting the camera again and checking speech

A stopped track cannot be restarted. Request a new video stream with getUserMedia() when the camera is needed again. If microphone capture is already running, request video only to avoid creating an additional audio capture track.

Keeping an audio track running does not establish that speech is audible or clear in a conferencing application. Confirm the application's selected microphone and use its microphone test or a short recording to check speech. No Chrome-version, webcam-model or voice-quality test evidence was supplied, so device-specific behavior and audio quality remain unverified.