Taking a screenshot
The previously created static prototype may look fancy, but is not of much use. We need a service capable of taking screenshots and recording screencasts.
If it was about a screenshot of the application window, we would simply use the API on NW.js:
import * as fs from "fs"; function takeScreenshot( filePath ){ appWindow.capturePage(( img ) => { fs.writeFileSync( filePath, img, "base64" ); }, { format : "png", datatype : "raw" }); }
But we need a screenshot of the screen and, therefore, we have to get access to display input. W3C includes a specification draft, "Media Capture and Streams" (http://bit.ly/2qTtLXX), which describes an API to capture displayed media (mediaDevices.getDisplayMedia
). Unfortunately, at the time of writing, it's not yet supported in NW.js or, to be honest, by any browser. However, we can still use webkitGetUserMedia
, which streams the desktop input. This API was once a part of technology known as WebRTC (https://webrtc...