simple-peer
simple-peer copied to clipboard
Add One more Stream to peer dynamically
Hi, I am adding screen sharing feature so i got screen share stream but when i add to that stream to peer its not working peer1.addStream(screenshareStream) is there any other method for addStream
We ended up adding multiple video tracks to one media stream. This allow us to share web cam and screen at the same time.
You can also use addTrack to add a single track to the stream
Hello @mokkymiah I was doing the same thing, adding tracks by addTrack(track,stream) method and gave event listener (on('track')) on the other peer. This doesn't seem to work here. Am I missing something?
var mystream = new MediaStream(); let peer = new Peer({ initiator: false, trickle: false, stream: mystream, reconnectTimer: 100, iceTransportPolicy: 'relay' }); anotherstream.getTracks().forEach(track => { peer.addTrack(track, mystream) });
client side:
peer.on('track', (track, stream) => {console.log(track);)
you can use replaceTrack instead of addTrack, it works for me
ReplaceTrack won’t solve for me, I need to add tracks (or media stream(without renegotiation). Can anyone give me some hint if it has worked before. Or is the RTCpeerconnection.addtrack() is usable with simple peer.
Hi, I'm also interested in this because when let's say you are changing your camera and for convenience, we assume you have added to the connection from the start a MediaSteam with a very important thing a VIDEO you can use the replaceTrack method but when let's say you need to add a video track using the addTrack method nothing happens and how can you know the track was really added?
Maybe @feross can you give as an idea on how this should at least work?
@saagarbethi I have the same issue, any update on this?