Chrome浏览器不允许HTTP托管站点访问Camera&麦克风 [英] Chrome is not letting HTTP hosted site to access Camera & Microphone

查看:110
本文介绍了Chrome浏览器不允许HTTP托管站点访问Camera&麦克风的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用反应网络摄像头来捕获应用程序的自拍照.在本地主机上,react-webcam完美运行,而在HTTP托管的Web服务器上,Chrome默认情况下拒绝访问摄像头.是否有任何可用于网络摄像头访问的变通办法或任何其他可以在此使用的npm插件.

I'm using react-webcam to capture a selfie for an application. On localhost, react-webcam works perfectly whereas on HTTP hosted web server camera access is being denied by default on the Chrome. Is there any workaround for webcam access or any other npm plugin which can serve the purpose here.

注意:允许HTTPS支持的网站访问Camera&麦克风.在这里,我只剩下HTTP选择.

NOTE: HTTPS supported sites are allowed to access both the Camera & Microphone. Here, I'm left with only HTTP choice.

推荐答案

react-webcam使用 getUserMedia API,该API

The react-webcam uses the getUserMedia API which specification states:

在不安全来源[混合内容]上时,鼓励用户代理警告使用navigator.mediaDevices.getUserMedia,navigator.getUserMedia以及其开发人员工具,错误日志等中所有带前缀的变体.明确允许用户代理在不安全来源上完全删除这些API ,只要它们一次删除所有API(例如,它们不应仅在不安全来源上保留可用的前缀版本).

When on an insecure origin [mixed-content], User Agents are encouraged to warn about usage of navigator.mediaDevices.getUserMedia, navigator.getUserMedia, and any prefixed variants in their developer tools, error logs, etc. It is explicitly permitted for User Agents to remove these APIs entirely when on an insecure origin, as long as they remove all of them at once (e.g., they should not leave just the prefixed version available on insecure origins).

从版本47开始的Chrome浏览器将实施此安全策略(来源):

Chrome, starting from version 47 implements this security policy (Source):

从Chrome 47开始,仅允许来自安全来源(HTTPS或本地主机)的getUserMedia()请求.

Starting with Chrome 47, getUserMedia() requests are only allowed from secure origins: HTTPS or localhost.

因此,如果没有安全的连接,您将无法访问麦克风或相机.

So you can't access Microphone or Camera without a secure connection.

这篇关于Chrome浏览器不允许HTTP托管站点访问Camera&麦克风的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆