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()
.
isCursorSupported = supportedConstraints.cursor;
A Boolean value which is
true
若
cursor
constraint is supported by the device and user agent.
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 */
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Screen Capture
The definition of 'MediaTrackSupportedConstraints.cursor' in that specification. |
未知 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
cursor
|
Chrome No | Edge No | Firefox No | IE No | Opera Yes | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
完整支持
不支持
兼容性未知
MediaDevices.getDisplayMedia()
MediaStreamTrack.getConstraints()
MediaStreamTrack.applyConstraints()
MediaStreamTrack.getSettings()
MediaTrackSupportedConstraints
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainBoolean
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaDevices
MediaStream
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackSettings
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()