Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

ON THIS PAGE

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

screenshot 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;                                                                                                                                                                                                                       
};  

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.

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

Screenshot

Use this interface to take screenshots.

syncCapture()
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()
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: 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: An optional description.
  • [int] width: The width of the image file. The default value is 640.
  • [int] height: The height of the image file. The default value is 480.
  • [int] 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.

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);
  • No labels