displaySurface约束不限制用户共享屏幕选择选项 [英] displaySurface constraint not restricting user share screen selection options

查看:459
本文介绍了displaySurface约束不限制用户共享屏幕选择选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加displaySurface不会在共享自己的屏幕之前引起用户的选项限制. 我试图将这些选项限制为仅允许用户选择浏览器选项卡以外的任何内容.

Adding displaySurface does not provoke option restriction for the user before sharing his own screen. I am trying to limit those options to only let the user select anything except browser tabs.

我尝试将displaySurface显式设置为显示器",并且仍然显示所有选项.

I tried setting displaySurface explicitly to 'monitor' and still all options being showed up.

async startCaptureMD() {
  let captureStream = null;
  var screen_constraints = {
     video: {
        cursor: "always",
        displaySurface: "monitor"
     }
  };
  try{
     captureStream = await 
     navigator.mediaDevices.getDisplayMedia(screen_constraints);
  }catch(err){
    console.log(err.message, err.code);
  }
  return captureStream;
},

预期结果是显示您的整个屏幕"或应用程序窗口",而不是"Chrome选项卡".

The expected result is to show 'Your Entire Screen' or 'Application Window' and not 'Chrome Tab'.

推荐答案

您不能. MDN 文档解释说它适用于安全性:

You can't. The MDN docs explain that it is for security:

约束永远不会导致可由Screen Sharing API捕获的源列表发生变化.这样可以确保Web应用程序通过限制源列表直到仅剩一项才可以强制用户共享特定内容.

Constraints never cause changes to the list of sources available for capture by the Screen Sharing API. This ensures that web applications can't force the user to share specific content by restricting the source list until only one item is left.

规范说:

用户代理必须让最终用户每次都从所有可用选择中选择要共享的显示表面,并且不得使用约束来限制该选择.

The user agent MUST let the end-user choose which display surface to share out of all available choices every time, and MUST NOT use constraints to limit that choice.

因此,浏览器在做正确的事情.看来displaySurface仅是一个输出值.如果您已有MediaStreamTrack来调用getSettings(),则可以阅读displaySurface.

So the browser is doing the right thing. It seems displaySurface is an output value only. If you already have a MediaStreamTrack to call getSettings() on, then you can read displaySurface.

我也很困惑,所以我修复了MDN文档. MDN文档需要更新,而不要将displaySurface列为表示允许用户选择的屏幕表面类型的字符串(或字符串数​​组)".

I also was confused, so I fixed the MDN docs. The MDN docs need updating to not list displaySurface as "A string (or array of strings) indicating what type or types of screen surface to allow the user to select".

这篇关于displaySurface约束不限制用户共享屏幕选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆