問題描述
我有一個網絡電子應用程序,我想在其中一個頁面中實現攝像頭.
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.
查看電子文檔以獲得更多幫助
這篇關于如何在電子應用程序中訪問相機/網絡攝像頭?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!