RTCMultiConnection icon indicating copy to clipboard operation
RTCMultiConnection copied to clipboard

Webcam, then switch to screenshare with replaceTrack()

Open mike131 opened this issue 9 years ago • 2 comments

I have taken basic example for RTCConnection from your getting started. I am using screenId.js and RTCMulticonnection.js

I am trying to replace the webcam using connection.replaceTrack({screen: true, oneway: true});

But when I do this, I still see the webcam, but now screenshare is added as well.

How can I replace it? Or am i not understanding the replaceTrack API properly?

mike131 avatar Nov 02 '16 18:11 mike131

replaceTrack API are/seems available only on Firefox.

var screenTrack = screenStream.getVideoTracks()[0];

connection.getAllParticipants().forEach(function(uid) {
   var peer = connection.peers[uid].peer;
   var sendes = peer.getSenders();
   senders.forEach(function(sender) {
      if(sender.track instanceof AudioStreamTrack) return; // skip audio
      sender.replaceTrack( screenTrack );
   });
});

applyConstraints API also requires Firefox.

muaz-khan avatar Nov 04 '16 14:11 muaz-khan

cannot switch webcam to screen share!!!

dotnethii avatar Mar 29 '21 18:03 dotnethii