要实现录音功能,但是navigator.mediaDevices 是 undefined这样解决

645 阅读1分钟

navigator.mediaDevices如果是undefined,则不能使用getUserMedia()

三个解决方法:

  1. 网页使用https访问

  2. 使用 localhost或127.0.0.1 进行访问

  3. 修改浏览器安全配置

    1)浏览器地址栏输入:chrome://flags/ #unsafely-treat-insecure-origin-as-secure

    2)修改 Insecure origins treated as secure 项

    改成Enabled

    在输入框输入你的域名

image.png 3)点击Relaunch,点击Relaunch,点击Relaunch,重要的事情说三遍 !!!