【问题标题】:WEBRTC - screen sharing without any extensionsWEBRTC - 没有任何扩展的屏幕共享
【发布时间】:2018-03-30 18:35:33
【问题描述】:

我有一个简单的问题。是否有可能实现适用于大多数设备和浏览器的屏幕共享?

我在网上找了一些 chrome 的插件,但我想在不安装任何插件或在 chrome 上设置一些实验标志的情况下进行屏幕共享。

最好的解决方案是当我可以从导航器获取流时,就像我的相机捕获一样。

从摄像头获取视频的代码

this.navig.getUserMedia =  ( this.navig.getUserMedia || this.navig.webkitGetUserMedia || this.navig.mozGetUserMedia || this.navig.msGetUserMedia );
this.navig.getUserMedia({video: true, audio: true}, (stream) => {
        this.videoElement.nativeElement.src = window.URL.createObjectURL(stream);
        this.videoElement.nativeElement.play();
}, (error) => console.warn('video error' + error))

所以我想用我的屏幕捕获流对象。这可能吗?

我在互联网上找到了这个,但这返回了一些错误...

navigator.mediaDevices.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);
  });

【问题讨论】:

    标签: javascript typescript webrtc


    【解决方案1】:

    2019 年更新:是的,这是可能的。 在 Chrome、Firefox 和 Safari 上使用 getDisplayMedia

    let displayMediaOptions = {video: true, audio: false};
    navigator.mediaDevices.getDisplayMedia(displayMediaOptions)
    .then(function(stream){
      video_el.srcObject = stream;
    })
    

    工作演示:thescreenshare.com

    【讨论】:

      【解决方案2】:

      在这个阶段,只有 firefox 允许您使用屏幕共享,而无需额外的安全插件或服务。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多