Search code examples
electronnw.js

Accessing the DOM between two renderers in Electron


Is it possible to do this in Electron:

I want to duplicate a video to a 2nd screen. This is easyly done, by invoking the following 50 times/second:

canvas_context_2nd_screen.drawImage(video_1st_screen,0,0,width_canvas_2nd,height_canvas_2nd);

but in electron i have to communicate via IPC... any ideas? is it possible in nw.js?


Solution

  • It is supported in NW.js. As DOM windows are in the same renderer process by default, and the Node.js context is shared between them:

    http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/

    This can be changed to be separate though.