共享并获取屏幕和摄像头p2p

时间:2020-09-29 21:33:58

标签: javascript webrtc

我希望与其他梨分享我的屏幕,并希望像这样进行网络摄像头聊天:

梨1 =共享屏幕+网络摄像头视频聊天 paer 2 =网络摄像头视频聊天和共享屏幕。

我的服务器上有

 const startScreenshare = async () => {
  try {
    const stream = await navigator.mediaDevices.getDisplayMedia({
      video: true,
      audio: true
    })
    if (!stream) throw new Error('Failed to get stream. is SSL configured?')

    let statusEl = document.getElementById('share-status')
    if (!statusEl) {
      statusEl = createShareStatusElement()
      document.getElementById('left-wrapper').prepend(statusEl)
    } else {
      statusEl.classList.remove('hidden')
    }
    const screenShareEl = document.getElementById('screenshare-wrapper')
    screenShareEl.classList.add('hidden')

    stream.getVideoTracks()[0].onended = () => {
      statusEl.classList.add('hidden')
      screenShareEl.classList.remove('hidden')
    }
    hub.peer.addStream(stream)
  } catch (err) {
    console.error(err)
  }
}

https://jsfiddle.net/skt095qb/

它运作良好,但它只共享屏幕,我想进行视频聊天,而一种方法是不共享音频。.

0 个答案:

没有答案