Open matheuscamarques opened 3 years ago
any old issue didn't help me much
If you're still looking for an answer, I was able to swap audio/video tracks at will using a function like this:
const peers = []; // list of connected peers
function replaceStream(newStream) {
const [ audioTrack = null ] = newStream.getAudioTracks();
const [ videoTrack = null ] = newStream.getVideoTracks();
peers.forEach(peer => {
const [ audioSender, videoSender ] = peer.call.peerConnection.getSenders();
audioSender.replaceTrack(audioTrack);
videoSender.replaceTrack(videoTrack);
});
}
where peer.call
is the MediaConnection created when calling/answering a remote peer (i.e. myPeer.on('call', call => console.log(call))
or const call = myPeer.call(remoteId, ...)
). Hope that helps.
How to switch from video/audio streaming to screen/audio streaming and back ?