【WebRtc】获取分享屏幕

分享前页面

image.png

获取分享屏幕

image.png

Code

 /**
     * 开始屏幕共享
     */
    openShareScreen() {
      var that = this
      // 判断是否支持获取本地屏幕分享数据
      if (!navigator.mediaDevices || !navigator.mediaDevices.getDisplayMedia) {
        that.$notify({
          title: '警告',
          message: '浏览器不支持本地屏幕设备',
          type: 'warning'
        });
        return;
      }
      const constraints = {
        audio: true,
        video: true
      };
      this.loading = true
      this.getLocalDisplayMedia(constraints).then(stream => {
        // 拿到流数据后,将流显示在video标签内
        this.setDomVideoStream('localVideo', stream);
        // 监听流
        stream.getVideoTracks()[0].onended = () => {
          //监听以后的处理逻辑……
          this.$notify({
            title: '提示',
            message: '屏幕共享已关闭',
            type: 'success'
          });
          that.closeUserMedia('localVideo')
        }
      });
    }

期待更新,麻烦点个赞,点个关注,栓Q !

本文作者:Hello、Lin

本文链接:https://www.cnblogs.com/HelloWxl/p/17214269.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Hello、Lin  阅读(143)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.