Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Cross-platform Desktop Application Development: Electron, Node, NW.js, and React

You're reading from   Cross-platform Desktop Application Development: Electron, Node, NW.js, and React Build desktop applications with web technologies

Arrow left icon
Product type Paperback
Published in Jul 2017
Publisher Packt
ISBN-13 9781788295697
Length 300 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
 Sheiko Sheiko
Author Profile Icon Sheiko
Sheiko
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface
1. Creating a File Explorer with NW.js-Planning, Designing, and Development FREE CHAPTER 2. Creating a File Explorer with NW.js – Enhancement and Delivery 3. Creating a Chat System with Electron and React – Planning, Designing, and Development 4. Creating a Chat System with Electron and React – Enhancement, Testing, and Delivery 5. Creating a Screen Capturer with NW.js, React, and Redux – Planning, Design, and Development 6. Creating a Screen Capturer with NW.js: Enhancement, Tooling, and Testing 7. Creating RSS Aggregator with Electron, TypeScript , React, and Redux: Planning, Design, and Development 8. Creating RSS Aggregator with Electron, TypeScript, React, and Redux: Development

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Visually different images