Search code examples
video-streamingchatwebrtcpubnubscreensharing

WebRTC and screen sharing using PubNub's API?


I am using PubNub's WebRTC API for video and audio conversations which works like a charm. Next I would like to add screen sharing to my application, but I can't find any useful info inside their documentation, in turn they have the option mentioned in several places.

the code I use right now:

var phone = window.phone = PHONE({
            number        :  $('#user_email').text() || "Anonymous", // listen on username line else Anonymous
            publish_key   : 'pub-xxx',
            subscribe_key : 'sub-xxx',
        }); 

        phone.ready(function(){ 
            $('#vid-box').show();
            $('#video-switch').addClass('switch-on');

            });

        phone.receive(function(session){
            session.connected(function(session) { 
            video_out.appendChild(session.video); 
            });

            session.ended(function(session) {
                 video_out.innerHTML='';
                  });
        });



    function startVideo(){
        if (!window.phone) {
             alert("Login First!");
             return false;

        } else {
             phone.dial( $('#other_side').text('ON') );
             $('#cam-button-text').text('Stop Video');
        }

    }

Solution

  • Please refer to SO thread How to use WebRTC + Pubnub Api for video chat client in Native android app

    And also, this PubNub demo/tutorial, Doodle with Strangers! Multi-User HTML5 Canvas in 4 Steps might be a more appropriate resource for what you are asking.