简体   繁体   English

原子电子:在另一个窗口中渲染画布

[英]Atom Electron: Render Canvas in Another Window

I have an Electron app with two BrowserWindows . 我有一个带有两个BrowserWindows的Electron应用程序。 The first manages multiple mediastreams which are rendered onto a canvas. 第一个管理呈现在画布上的多个媒体流。 When running the app in the browser I can access the canvas in a popup using the document reference provided by window.open() . 在浏览器中运行应用程序时,我可以使用window.open()提供的文档引用在弹出窗口中访问画布。 Is something like this possible in Electron? 在Electron中有可能发生这种情况吗?

Is it possible to pass a CanvasRenderingContext2D using the ipcRenderer to the other window? 是否有可能通过一个CanvasRenderingContext2D使用ipcRenderer到另一个窗口? Or via a global on the main process? 还是通过全局的主要流程?

ipcRenderer and ipcMain do not support complex things transfer like objects or functions. ipcRendereripcMain不支持对象或函数之类的复杂事物传输。 You need to send your instructions from your first BrowserWindow to your main process, then the main process should send an instruction (like a string) to your second window that should handle it. 您需要将指令从第一个BrowserWindow发送至主进程,然后主进程应将指令(如字符串)发送至第二个应处理该指令的窗口。

If you want to transfer streams, you will have to create a localhost server and use a socket library ( socket.io ), coupled with the corresponding npm package, for example socket.io-stream 如果要传输流,则必须创建一个本地主机服务器并使用套接字库( socket.io ),再加上相应的npm包,例如socket.io-stream

也许WebRTC可以为您工作,例如: http : //www.html5rocks.com/en/tutorials/webrtc/basics/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM