MediaTrackSupportedConstraints.cursor
The MediaTrackSupportedConstraints
dictionary's cursor
property indicates whether or not the cursor
constraint is supported by the user agent and the device on which the content is being used.
The supported constraints list is obtained by calling navigator.mediaDevices.getSupportedConstraints()
.
Syntax
isCursorSupported = supportedConstraints.cursor;
Value
A Boolean value which is true
if the cursor
constraint is supported by the device and user agent.
Example
This method sets up the constraints object specifying the options for the call to getDisplayMedia()
. It adds the cursor
constraint only if it is known to be supported by the browser. Capturing is then started by calling getDisplayMedia()
and attaching the returned stream to the video element referenced by the variable videoElem
.
async function captureWithCursor() { let supportedConstraints = navigator.mediaDevices.getSupportedConstraints(); let displayMediaOptions = { video: { displaySurface: "browser" }, audio: false; }; if (supportedConstraints.cursor) { displayMediaOptions.video.cursor = "always"; } try { videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions); } catch(err) { /* handle the error */ } }
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
cursor |
No |
No |
No |
No |
Yes |
No |
No |
No |
No |
? |
No |
No |
See also
- Screen Capture API
- Using the screen capture API
- Capabilities, constraints, and settings
MediaDevices.getDisplayMedia()
MediaStreamTrack.getConstraints()
MediaStreamTrack.applyConstraints()
MediaStreamTrack.getSettings()
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSupportedConstraints/cursor