Hey okai...
This might help you, you have to replace the track:
to start screen share:
var option = {video: {mediaSource: 'screen'}, audio: true};
navigator.mediaDevices.getDisplayMedia(option)
.then(function(streams){
var videoTrack = streams.getVideoTracks()[0];
var sender = pc.getSenders().find(function(s) { // pc refers to => session.sessionDescriptionHandler.peerConnection;
return s.track.kind == videoTrack.kind;
});
console.log('found sender:', sender);
sender.replaceTrack(videoTrack);
}, function(error){
console.log("error ", error);
});
to stop screen share again coming back to old video:
var option = {video: true, audio: true};
navigator.mediaDevices.getUserMedia(option)
.then(function(streams){
var videoTrack = streams.getVideoTracks()[0];
var sender = pc.getSenders().find(function(s) { // pc refers to => session.sessionDescriptionHandler.peerConnection;
return s.track.kind == videoTrack.kind;
});
console.log('found sender:', sender);
sender.replaceTrack(videoTrack);
}, function(error){
console.log("error ", error);
});
Thanks