Screen Capture with getDisplayMe

2018-05-04  本文已影响230人  耦耦

1、getUserMedia与getDisplayMedia*比较


除了下面提到的几点,其他操作,两者是相同的。

getUserMedia

getDisplayMedia

2、getDisplayMedia例子


navigator.getDisplayMedia({ video: true })
  .then(stream => {
    // we have a stream, attach it to a feedback video element
    videoElement.srcObject = stream;
  }, error => {
    console.log("Unable to acquire screen capture", error);
  });

3、用户权限


Demo


测试地址:https://ouchunrun.github.io/capture_screen_with_getDisplayMedia/
这里我使用的是Adapter.js库

测试截图是这样的:
(对等端的显示在5S左右,需要稍加等待)

image.png

和上面提到的一样,他需要是一个HTTPS源才能访问。
右下方也能看到,这里的对等连接时的RTCPeerConnection调用的是Adapter.js里面封装的方法,而不是浏览器自带的。

浏览器自带的时这样子的:


image.png

参考


Bringing Screen Capture to Microsoft Edge with the Media Capture API

Screen Capture

上一篇 下一篇

猜你喜欢

热点阅读