You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

最新浏览器中getUserMedia抛出DevicesNotFoundError问题求助

Fixing getUserMedia() Issues in Chrome 63 and Firefox 57.0.4

Hey there, let's work through this getUserMedia problem you're hitting after browser updates. Those versions introduced some key changes that are likely breaking your existing code—here are the most common fixes:

1. Replace the deprecated navigator.getUserMedia with the modern API

The old callback-based navigator.getUserMedia has been phased out, and browsers like Chrome 63+ and Firefox 57+ are restricting support for it. The modern standard is navigator.mediaDevices.getUserMedia, which uses Promises for cleaner, more consistent error handling.

Here's how to update your code:

// Modern replacement for your original code
navigator.mediaDevices.getUserMedia({ "audio": true, "video": false })
  .then(function(stream) {
    console.log(stream);
    localStream = stream;
  })
  .catch(function(err) {
    console.error("Error accessing media devices:", err);
  });

2. Ensure you're using HTTPS (except for local development)

Chrome 60+ enforces a secure context requirement for media device access. That means unless you're testing on localhost, 127.0.0.1, or a private IP, your site must be served over HTTPS. If you're running your code on a public domain without HTTPS, the browser will block getUserMedia requests entirely.

For local development, localhost still works fine—no need for HTTPS there. For production, you can set up a free SSL certificate via services like Let's Encrypt.

3. Double-check browser permissions

Browser updates sometimes reset site permissions. Make sure your browser hasn't revoked access to your microphone:

  • In Chrome: Click the lock icon in the address bar → Site settings → Ensure "Microphone" is set to "Allow".
  • In Firefox: Click the info icon (i) in the address bar → Permissions → Set "Microphone" to "Allow".

If permissions were set to "Block", that would explain why getUserMedia fails silently or throws a permission error.

4. Check for browser policy restrictions

If you're working in a corporate environment, there might be group policies or enterprise settings that block media device access. Reach out to your IT team to confirm if there are any restrictions on Chrome or Firefox that would prevent access to audio devices.


内容的提问来源于stack exchange,提问作者Akshay komarla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:57:46