Detect Firefox support for screen sharing

我的未来我决定 提交于 2019-12-23 13:10:54

问题


Firefox, since version 52, will support screen sharing via:

navigator.mediaDevices.getUserMedia({ video: { mediaSource: 'screen' }}) 
  .then(stream => { ... });

Check out this test page to see it in action.

I would like to know whether there is a way to detect whether a browser supports { mediaSource: 'screen' }?

I would like to only give the option to share the screen with users that have the ability to share. So I'd like to be able to feature detect this.


回答1:


a way to detect whether a browser supports { mediaSource: 'screen' }?

The pedantic answer is the following will tell you if the mediaSource constraint is supported:

console.log(!!navigator.mediaDevices.getSupportedConstraints().mediaSource);

Unfortunately, mediaSource is non-standard, and only implemented in Firefox. Firefox is as of this writing the only browser to enable screen-sharing without a plugin.

Chrome has a different non-standard API using chromeMediaSource available as a plug-in, using an older constraints syntax, but it (rightly) does not appear in the new getSupportedConstraints.

It's a bit of a mess still. Long-term browsers may end up implementing getDisplayMedia instead.



来源:https://stackoverflow.com/questions/46101264/detect-firefox-support-for-screen-sharing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!