Search code examples
webwebrtc

Can you help me for implementing screen sharing in a webRTC based peer to peer connection?


I was to build a video chatting application based on webRTC. It is pretty muchh eassy to get the screen sharing stream by the specific API. But I am quitely unable to stitch with the ongoing peer to peer connection. Can any one provide with necessary updated resource and ideas for implementing?


Solution

  • in peer to peer connection, we mostly use getUserMedia to get our videos to others.

    To share my screen view to the other person, you can use getDisplayMedia to share the screen.

         navigator.mediaDevices.getDisplayMedia({
            audio:true, video:true
         }).then(async function(stream){
            
         }).catch(error=> console.log(error));
    

    this is the basic example that I used in my program