What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To preview a webcam in a web page, request video access with navigator.mediaDevices.getUserMedia({ video: true, audio: false }), assign the returned stream to a <video> element’s srcObject, and stop its tracks when the preview ends. The page normally needs to run over HTTPS, and the visitor must grant camera permission. The example below adds Start and Stop buttons, handles common failures, and does not request microphone access.
What a browser webcam preview needs
A live preview is not an image or a video file. The browser asks for permission to use a camera, then provides a MediaStream containing its video track. Assign that stream to a video element to show the live feed.
- A secure page: serve the page over HTTPS in production.
localhostandfile:///are documented secure-context cases for local development. - User permission: the browser prompts the user when the page requests camera access. Explain why the camera is needed and start the request after a clear action, such as pressing a Start camera button.
- A usable camera: permission does not guarantee a feed. A camera may be unavailable, in use, blocked by policy, or unable to meet requested constraints.
If navigator.mediaDevices is undefined, check the page’s security context before treating the problem as a JavaScript bug.
Show a live camera feed in a video element
This complete example requests video only, starts on a button click, reports errors in the page, and releases the camera when the user stops the preview.
#1 Best Overall
- Compatible with Nintendo Switch 2’s new GameChat mode
- Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
- The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
- C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
- The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
<video id="preview" autoplay muted playsinline></video>
<button id="start">Start camera</button>
<button id="stop" disabled>Stop camera</button>
<p id="status" role="status"></p>
<script>
const video = document.querySelector('#preview');
const start = document.querySelector('#start');
const stop = document.querySelector('#stop');
const status = document.querySelector('#status');
let stream;
start.addEventListener('click', async () => {
try {
stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false });
video.srcObject = stream;
await video.play();
status.textContent = 'Camera preview is running.';
start.disabled = true;
stop.disabled = false;
} catch (error) {
status.textContent = `${error.name}: ${error.message}`;
}
});
stop.addEventListener('click', () => {
stream?.getTracks().forEach((track) => track.stop());
video.srcObject = null;
start.disabled = false;
stop.disabled = true;
status.textContent = 'Camera stopped.';
});
</script>
What each part does
getUserMedia()requests a stream. The browser’s permission prompt is tied to this request; it is not a guarantee that a camera exists or will open successfully.{ video: true, audio: false }asks only for a camera feed. Do not request microphone access unless audio capture is a deliberate part of the feature.video.srcObject = streamconnects the live stream to the video element. A file URL such asvideo.srcis not the right way to attach this stream.- The Start button makes the permission request understandable and avoids prompting as soon as the page loads.
- The Stop handler stops every track and clears
srcObject, releasing the camera instead of merely hiding the preview.
Why autoplay, muted, and playsinline belong together
Use autoplay muted playsinline on the preview element. Muted inline video is the practical pattern for autoplay; Safari requires playsinline for autoplay. Autoplay rules apply both to the autoplay attribute and to a JavaScript call to video.play().
The example still calls and awaits video.play(). That makes a rejected playback promise visible to the same error handler as a rejected camera request, rather than leaving the user with a blank-looking video element. If your interface has a separate playback control, handle that promise there as well.
Choose a camera or request a particular resolution
Begin with the default camera
For a basic preview, { video: true, audio: false } is the simplest request. Add constraints only to meet a real product requirement. For example, a 1280-by-720 preference can be requested as:
const stream = await navigator.mediaDevices.getUserMedia({
video: { width: 1280, height: 720 },
audio: false
});
A requested resolution may not be available on every camera. If a constraint cannot be satisfied, the request can fail with OverconstrainedError; provide a fallback or relax the constraint rather than leaving the preview unusable.
Rank #2
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
Offer a camera picker
If users need to choose among cameras, obtain device information with navigator.mediaDevices.enumerateDevices() after permission, then request the selected camera using its deviceId. Device information may be limited before the user grants permission, so do not assume a complete picker list is available before a successful access request.
Use constraints as preferences unless your interface explicitly handles a device that cannot meet them. A picker should also handle the case where the selected device disappears or is unavailable when the user starts the preview.
Make the preview work inside an iframe
An embedded page may be blocked from using the camera even when the visitor has granted permission. The parent page must delegate camera access through Permissions Policy, including an appropriate camera policy and allow="camera" on the iframe. A NotAllowedError in an embedded preview can therefore indicate a policy restriction, not just a visitor denial.
Explain camera errors and recovery
Show a useful status instead of replacing every failure with “Camera unavailable.” The example exposes the error name and message; a production interface can turn those into clear next steps.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteRank #3
- 1080P HD Webcam: This HD webcam delivers crisp 1080p video quality, ideal for PCs, desktops, and laptops. Perfect for video calls, online classes, meetings, live streaming, gaming, and everyday recording. It provides clear, sharp images and smooth video at up to 30 frames per second. This live streaming webcam works with platforms such as Zoom, Teams, FaceTime, Google Meet, and YouTube.
- USB Plug and Play Webcam: Designed for PCs, this webcam is easy to use. No drivers or software are required; simply connect the webcam to your computer and start using it immediately. Operation is smooth and convenient. XWEIRYN webcams are compatible with multiple operating systems, including Mac/Windows XP/7/8/10/11/PC/Laptops.
- Widely Compatible Webcam: This versatile webcam is compatible with most operating systems and major video platforms. As a reliable computer webcam, it supports video conferencing, remote learning, live streaming, and gaming, meeting your various needs for daily work and entertainment.
- Smooth and Stable Performance: This webcam uses a stable transmission chip to ensure smooth, lag-free video streaming, synchronized audio and video, and no dropped frames. Even after prolonged use, this durable webcam maintains stable performance. It performs excellently even in low-light environments. It automatically adjusts to adapt to low-light conditions, reducing noise and restoring vibrant colors, ensuring clear and sharp images even without additional studio lighting.
- Compact and Adjustable Design: This lightweight and portable webcam saves space and comes with an adjustable clip. Our USB webcam uses a reliable USB 2.0/3.0 connection and comes with an upgraded 1.5-meter (5-foot) braided cable. It is compatible with Desktop most monitors and Laptop. Its portable design makes it easy to place and carry, ideal for home, office, or travel use.
| Error | What it can mean | Useful response |
|---|---|---|
NotAllowedError |
The user denied access, the page is insecure, or Permissions Policy blocks the request. | Explain how to allow camera access, check that the page is served securely, and, for an iframe, verify camera delegation. |
NotFoundError |
No camera satisfies the requested video constraints. | Check whether a camera is connected and retry with less restrictive constraints. |
NotReadableError |
Permission was granted, but the operating system, hardware, or page could not read the camera. | Check whether another application is using the camera and whether the operating system can access it; then offer a retry. |
OverconstrainedError |
The requested width, height, facing mode, or device selection cannot be satisfied. | Relax the requirement or try a different camera instead of repeatedly requesting the same constraints. |
TypeError |
The constraints are empty or false, or the API is unavailable in an insecure context. | Check the request options and page security context before changing camera hardware or permissions. |
These causes can overlap in a user’s experience: for example, a blocked insecure page may look like a permission problem. Preserve the error name for debugging, but give visitors an action they can take rather than asking them to interpret an exception.
Stop the camera at the right time
Stopping playback visually is not the same as stopping camera capture. Call stop() on every stream track, then clear video.srcObject. Keep this cleanup in the Stop control and also call it when the application ends the preview through another route, such as closing a camera dialog or navigating away within a single-page interface.
Browsers display camera-use indicators while access is active. Make the preview state and Stop control clear, and request no microphone permission for a camera-only feature. If a user stops the preview, release the stream rather than leaving it open in the background.
Compatibility and legacy code
navigator.mediaDevices.getUserMedia() is the modern promise-based API and is widely available; MDN records browser support beginning in September 2017. Use it for new work. The older callback-based navigator.getUserMedia() method is deprecated. Permission interfaces and autoplay behavior can differ by browser, so test the actual browsers and devices your application supports.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #4
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
Troubleshooting: how do I preview my webcam in the browser?
The permission prompt never appears
Confirm that the page is in a secure context and that the request runs after the Start button is clicked. If the page is embedded, inspect its camera Permissions Policy and iframe allow setting. A previously denied permission may also prevent the expected prompt; the visitor may need to change the browser’s site permission.
The browser says access is unavailable
Check for a connected camera and whether another application or the operating system is preventing access. Confirm that your code requests only the constraints the device can satisfy. Use the actual error name to distinguish a missing device from a hardware-read failure or a constraint mismatch.
The video element stays blank after permission
Verify that the stream is assigned to video.srcObject, that the element has autoplay muted playsinline, and that the awaited video.play() promise is handled. Permission alone does not establish that playback started.
It works locally but fails after deployment
Check that the deployed page uses HTTPS. Local development can work in documented secure contexts such as localhost or file:///; that does not make an ordinary insecure production page a secure context.
Recommended Free Tools
Best Value
The camera picker is empty or a selected camera fails
Enumerate devices after permission and handle unavailable device IDs. Start from a default-camera request, and do not assume that a selected device will remain present or satisfy every resolution constraint.
Or skip the browser setup
ScreenshotNeo is a website screenshot API, not a webcam-preview API: it cannot display a visitor’s live camera feed. Use the browser method above for that. If what you need instead is a screenshot of a web page, ScreenshotNeo accepts a URL and returns an image or PDF. This one-call example saves a WebP screenshot of Stripe:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card. Learn more at ScreenshotNeo.
Frequently Asked Questions
Can a browser preview a webcam without asking for permission?
No. The page must request camera access, and the browser requires the user’s permission before providing the camera stream.
Does this webcam preview code record or upload video?
No. The example displays a local live stream and does not record or upload it.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

