如何在电子应用程序中访问相机/网络摄像头? [英] How to access camera/webcamera inside electron app?

查看:12
本文介绍了如何在电子应用程序中访问相机/网络摄像头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络电子应用程序,我想在其中一个页面中实现摄像头.

I have a web electron application and I want to implement camera in one of the pages.

问题是最近出于安全原因,网络摄像头只能通过https"访问.但是对于在本地提供应用程序的 Electron 应用程序,方案是不同的,因此流式传输失败.所以我的问题是:

The problem is that lately for security reasons webcam can only be accessed via 'https'. But in case of an Electron app where the application is served locally the scheme is different and therefore streaming fails. So my question is:

有什么好的解决方案可以在电子内部实现网络摄像头吗?

如果不行,除了网络摄像头还有什么解决方案可行?

推荐答案

我正在回答我自己的问题,以防它帮助其他人.在我的情况下,a 有一个自定义方案,而不是标准方案,即 file 但我遗漏了一些东西.我发现我只需要在 registerStandardSchemes(版本 4)中添加:{ secure: true }.这让 electron 知道这个方案是安全的,并且足以让网络摄像头工作.

I am answering my own question in case it helps anyone else. In my case a had a custom scheme instead of the standard one which is file but I was missing something. I found out I just had to add: { secure: true } inside registerStandardSchemes(version 4). That makes electron know that this scheme is secure and that is enough for webcam to work.

查看电子文档以获得更多帮助

这篇关于如何在电子应用程序中访问相机/网络摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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