GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

CaptureController: CaptureController() constructor

Screen Capture API

Screen Capture API

The CaptureController constructor creates a new `CaptureController` object instance.

## Syntax

```js-nolint
CaptureController()
```

### Parameters

None.

## Examples

```js
// Create a new CaptureController instance
const controller = new CaptureController();

// Prompt the user to share a tab, window, or screen.
const stream = await navigator.mediaDevices.getDisplayMedia({ controller });

// Query the displaySurface value of the captured video track
const [track] = stream.getVideoTracks();
const displaySurface = track.getSettings().displaySurface;

if (displaySurface === "browser") {
// Focus the captured tab.
controller.setFocusBehavior("focus-captured-surface");
} else if (displaySurface === "window") {
// Do not move focus to the captured window.
// Keep the capturing page focused.
controller.setFocusBehavior("no-focus-change");
}
```

## Specifications

## Browser compatibility

## See also

- [Screen Capture API](/docs/Web/API/Screen_Capture_API)
- MediaDevices.getDisplayMedia()
- [Better screen sharing with Conditional Focus](https://developer.chrome.com/docs/web-platform/conditional-focus/)

source: MDN Web Docs mirror · page

Cite this

"CaptureController: CaptureController() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/CaptureController/CaptureController

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·