Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The screenshot object allows you to capture a screenshot of the composite video and graphics layers.

screenshot IDL

Code Block
title
languagejsscreenshot IDL
interface Screenshot {                                                                                                                                                                                                                                                  
    void syncCapture(ScreenshotParams params);                                                                                                                                                                                                                          
    Promise<void> asyncCapture(ScreenshotParams params);                                                                                                                                                                                                                
};                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                        
interface ScreenshotParams {                                                                                                                                                                                                                                            
    [optional] attribute String destinationFileName;                                                                                                                                                                                                                    
    [optional] attribute String fileName;                                                                                                                                                                                                                               
    [optional, Default=JPEG] attribute String fileType;                                                                                                                                                                                                                 
    [optional, Default=""] attribute String description;                                                                                                                                                                                                                
    [optional, Default=640] attribute int width;                                                                                                                                                                                                                        
    [optional, Default=480] attribute int height;                                                                                                                                                                                                                       
    [optional, Default=50] attribute int quality;                                                                                                                                                                                                                       
    [optional, Default=0] attribute int rotation;                                                                                                                                                                                                                       
};  
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px



Object Creation

To create a screenshot object, first load the brightsign/screenshot module using the require() method. Then create an instance of the screenshot class.

Code Block
languagejs
var ScreenshotClass = require("@brightsign/screenshot");
var screenshot = new ScreenshotClass();

Screenshot

Use this interface to take screenshots.

syncCapture()
Code Block
languagejs
void syncCapture(ScreenshotParams params) 

Takes a screenshot at nearly the exact moment that it is called. Because this method might interrupt on-screen operations, it is more appropriate for debugging applications.

asyncCapture()
Code Block
languagejs
Promise<void> asyncCapture(ScreenshotParams params)

Takes a screenshot without interrupting other operations. This method is appropriate for production environments–where the timing of the capture is less important than seamless operation.

ScreenshotParams

This interface contains screenshot settings.

  • [String] destinationFileName: The native path and filename that will be saved.

  • [String] fileName: The name and path of the image file that will be saved (e.g. "SD:/myscreenshots/screen.jpg"). If the specified directory does not exist, the screenshot will fail. This is deprecated in favor of destinationFileName, but is still supported. 

  • [String]

 fileType
  •  fileType: The file type of the image ("JPEG" or "BMP"). The default file type is "JPEG". Note that the file extension (".jpg" or ".bmp") is not appended to the filename by default and, if needed, should be included in the fileName string.

  • [String]

 description
  •  description: An optional description.

  • [int] width: The width of the image file. The default value is 640.

  • [int]

 height
  •  height: The height of the image file. The default value is 480.

  • [int]

 quality
  •  quality: The image quality of the screenshot (between 0 and 100). The default value is 50.

  • [int] rotation: The rotation of the screenshot image (in degrees). The default value is 0. Accepted values are 0, 90, 180, and 270.

Example

This script takes a screenshot asynchronously every five minutes, saving it to the root of the SD card. Note that the previous image is erased with each new screenshot.

Code Block
languagejs
var ScreenshotClass = require("@brightsign/screenshot");
var screenshot = new ScreenshotClass();

function takeAsyncScreenshot(args) {
    screenshot.asyncCapture(args).then().catch();
};

screenshotParams = {};
screenshotParams.fileName = "SD:/screen.jpg";
screenshotParams.quality = 75;

setInterval(takeAsyncScreenshot(screenshotParams), 10000);