simple-peer icon indicating copy to clipboard operation
simple-peer copied to clipboard

Add One more Stream to peer dynamically

Open saagarbethi opened this issue 4 years ago • 6 comments

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

saagarbethi avatar Aug 15 '20 15:08 saagarbethi

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

mokkymiah avatar Aug 16 '20 07:08 mokkymiah

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);)

shlok-ps avatar Sep 04 '20 08:09 shlok-ps

you can use replaceTrack instead of addTrack, it works for me

saagarbethi avatar Sep 04 '20 08:09 saagarbethi

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.

shlok-ps avatar Sep 04 '20 17:09 shlok-ps

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?

Mihai-github avatar Sep 12 '22 19:09 Mihai-github

@saagarbethi I have the same issue, any update on this?

ayahabeeb98 avatar Jan 03 '23 16:01 ayahabeeb98