muaz-khan / RTCMultiConnection

RTCMultiConnection is a WebRTC JavaScript library for peer-to-peer applications (screen sharing, audio/video conferencing, file sharing, media streaming etc.)
https://muazkhan.com:9001/
MIT License
2.55k stars 1.38k forks source link

how to change the video for screen capture? #1016

Open matheuscamarques opened 3 years ago

matheuscamarques commented 3 years ago

how to change the video for screen capture?

matheuscamarques commented 3 years ago

Funcitonal code.

 async function startCapture() {
            if (activeStream % 2) {
                connection.addStream({
                    screen: true,
                    audio: true,
                    oneway: true,
                });
                console.log(activeStream);
                activeStream++;
            } else {
                connection.addStream({
                    audio: true,
                    video: true,
                    oneway: true,
                });
                console.log("Connection video", activeStream);
                activeStream++;
            }
        }
var stream1 = {}
connection.onstream = function (event) {
            if (stream1) {
                stream1.stop();
                stream1 = event.stream;
        }

     //connection code is here
    stream1 = event.stream;
}