新版Chrome访问http页面无法打开麦克风、摄像头

原因分析:

1、http协议的网站的安全原因,不能访问本地的麦克风

2、允许打开麦克风的请求有http://localhost/以及https请求。

 

解决方法:

方法一:

访问摄像头,麦克风等必须使用https,将网站部署成https请求

方法二:

官方解释:

You can run chrome with the --unsafely-treat-insecure-origin-as-secure="http:example.com" flag (replacing "example.com" with the origin you actually want to test), which will treat that origin as secure for this session. Note that on Android and ChromeOS this requires having a device with root access/dev mode. (This flag is broken in Chrome 63 but fixed in Chrome 64 and later. Prior to Chrome 62, you must also include the --user-data-dir=/test/only/profile/dir to create a fresh testing profile for the flag to work.)

右键点击Chrome桌面快捷方式,打开属性

在 “快捷方式页-目标”最后输入以下内容

 --unsafely-treat-insecure-origin-as-secure="http://example.com"  --user-data-dir=/test/only/profile/dir

新版Chrome访问http页面无法打开麦克风、摄像头_第1张图片

注意:

    1、"--"前要保留一个空格;

    2、" --user-data-dir=/test/only/profile/dir",不可缺少,很多文章都是因为缺少该配置,无法实现http网页打开麦克风、摄像头。

 

 

你可能感兴趣的:(前端)