The Screen Capture API introduces additions to the existing Media Capture and Streams API to let the user select a screen or portion of a screen (such as a window) to capture as a media stream. This stream can then be recorded or shared with others over the network.
The Screen Capture API is relatively simple to use. Its sole method is
MediaDevices.getDisplayMedia(), whose job is to ask the user to select a screen or portion of a screen to capture in the form of a
To start capturing video from the screen, you call
captureStream = await navigator.mediaDevices.getDisplayMedia(
Promise returned by
getDisplayMedia() resolves to a
MediaStream which streams the captured media.
See the article Using the Screen Capture API for a more in-depth look at how to use the API to capture screen contents as a stream.
The Screen Capture API adds properties to the following dictionaries defined by other specifications.
User agents that support Permissions Policy (either using the HTTP
Permissions-Policy header or the
allow) can specify a desire to use the Screen Capture API using the directive
<iframe allow="display-capture" src="/some-other-document.html">…</iframe>
The default allowlist is
self, which lets any content within the same origin use Screen Capture.