是否可以禁止使用 getDisplayMedia() 记录光标

Is it possible to disable the cursor from being recorded with getDisplayMedia()

我正在使用 MediaStream 和 MediaRecorder 录制我的浏览器 window。

但是需要禁止鼠标光标被记录,所以当我创建我的视频轨道时,我使用以下代码:

stream['input'] = await navigator.mediaDevices.getDisplayMedia({
    audio: true,
    video: {
    cursor: 'never',
    frameRate: 40,
}
});
console.log( stream['input'].getVideoTracks()[0].getSettings() );

但是 chrome,opera 和 edge 控制台显示:

aspectRatio: 1.7777777777777777
cursor: "motion"
deviceId: "window:200730:1"
displaySurface: "window"
frameRate: 40
height: 1080
logicalSurface: true
resizeMode: "crop-and-scale"
width: 1920

但是好像忽略了设置,所以光标正在被记录。

我可以看到在我的控制台中设置了 frameRate 约束,但是我似乎终生无法禁用光标。

然而,firefox 不记录光标并在控制台中显示它

frameRate: 40
​height: 924
​width: 1263

有没有人成功地使用 Chrome、Edge 和 Opera 完全禁用光标?

我什至尝试过使用

stream['input'].getVideoTracks()[0].applyConstraints( { 
video: { cursor: 'never', frameRate: 30 } 
} );

哪个不起作用:-(

更新: 我可以从这里的图表中看到: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints

游标约束只应在 Opera 上受支持。但是 getSupportedConstraints() 的输出显示毕竟不支持游标。

谢谢

在此页面底部,您会发现 table 显示浏览器对各种“MediaTrackConstraints”属性的支持。

https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSupportedConstraints

遗憾的是,

cursor 并未得到广泛支持。

您可以使用 getSupportedConstraints() 查看您的代码所在的浏览器支持的内容 运行。

在您的开发工具控制台中试试这个,看看您的浏览器可以做什么,或者更可能不能做什么。

console.log(navigator.mediaDevices.getSupportedConstraints())