Class: Screen

Screen

Screen class is used for representing the display of the computer. It can be used to capture the contents of the entire screen or a portion thereof (such as a window of an application or a tab of the browser). Screen class implements MediaStreamVideoSupplier interface, so it can be used as a source of video for local MediaStream.

let screen = MindSDK.getScreen();
if (screen) {
    screen.setFps(5);
    let mySecondaryStream = MindSDK.createMediaStream(null, screen);
    me.setSecondaryMediaStream(mySecondaryStream);
    screen.acquire().catch(function(error) {
        alert("Screen can't be acquired: " + error);
    });
} else {
    alert("Screen capturing isn't supported");
}

Classes

Screen

Methods

acquire() → {Promise}

Starts screen capturing. This is an asynchronous operation which assumes prompting the user to select and grant permission to capture the contents of a screen or portion thereof (such as a window) and distributing screen's video among all consumers. This method returns a Promise that resolves with no value (if the screen capturing starts successfully) or rejects with an Error (if the user didn't grant permission to access the screen or canceled the operation). If screen capturing has been already started, this method returns already resolved Promise.

Returns:

The promise that either resolves with no value or rejects with an Error.

Type
Promise

release()

Stops screen capturing. This is a synchronous operation which assumes revoking previously distributed screen's video. The stopping is idempotent: the method does nothing if the screen is not acquired.

setFps(fps)

Sets frame rate which the screen should use for capturing video. The frame rate can be set at any moment regardless whether the screen is acquired or not.

Parameters:
Name Type Description
fps Number

The frame rate which the screen should capture video at.

setListener(listener)

Sets the listener which should be notified of all events related to the screen.

Parameters:
Name Type Description
listener ScreenListener

The listener which should be notified of all events related to the screen.