Detect Firefox support for screen sharing

前端 未结 1 1737
不思量自难忘°
不思量自难忘° 2021-01-19 11:28

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

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


        
相关标签:
1条回答
  • 2021-01-19 12:19

    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.

    0 讨论(0)
提交回复
热议问题