javascript - Chrome 中的网络摄像头 js 错误 : Could not access webcam

标签 javascript google-chrome webcam webcam.js

我在我的一个项目中使用 Webcam JS。

https://github.com/jhuckaby/webcamjs

我使用的版本:1.0.0 可用的最新版本:1.0.5

它在 Chrome 和 Firefox 中都运行良好。但最近网络摄像头错误开始仅在 CHROME 中显示。 Firefox 仍然可以正常工作。

我在 1.0.0 中收到的错误:Webcam.JS 错误:无法访问网络摄像头。

我升级了版本,现在我在 chrome 中遇到的错误是

Webcam.js Error: Could not access webcam.
Permission Error: Only secure origins are allowed

https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features

我的网站有一个安全来源。

谁能告诉我为什么我会遇到这样的错误?

我认为复制粘贴 webcam.js 代码没有意义。

这是我使用的代码:

Webcam.set({
      width: 320,
     height: 240,
     dest_width: 320,
     dest_height: 240,
     image_format: 'jpeg',
     jpeg_quality: 90,
     force_flash: false
    });
    Webcam.attach( '#my_camera' );

最佳答案

Chrome 47 要求网站是 HTTPS 以便用户媒体/网络摄像头工作!这是一个全新的要求,我没有预见到...

有关该主题的 Chromium 文档: https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features

这意味着我必须购买 SSL 证书。只要您在 127.0.0.1 上或通过 HTTPS 使用该库,它就可以在 Chrome 47 中正常运行。

Issue Discussion

Solution

关于javascript - Chrome 中的网络摄像头 js 错误 : Could not access webcam,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34081919/

相关文章:

javascript - 鼠标光标根据事件变化

javascript - 使用javascript或css更改html5中var的颜色和重量

javascript - 使用 JavaScript 和 Google Chrome 创建和打开新窗口并打印图像

从相机读取时 C++ OpenCV 0xC0000005 错误

windows - Directshow - 识别内置(集成摄像头)与外部 USB 摄像头

javascript - jQuery:根据动态添加的类选择元素?

javascript - 如何在 Chrome 扩展程序卸载/禁用时清理网页

google-chrome - 使用适用于 Chrome 的 VSCode 扩展调试器同时运行多个项目

c++ opencv网络摄像头流到html

php - 如何使用 Google Map API 计算并显示特定地点的风向?