Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peer.addStream(stream) doesn't raise event one other peer #840

Open
Gruski opened this issue Sep 10, 2021 · 2 comments
Open

peer.addStream(stream) doesn't raise event one other peer #840

Gruski opened this issue Sep 10, 2021 · 2 comments

Comments

@Gruski
Copy link

Gruski commented Sep 10, 2021

using: v9.11.0
library directly referenced: <script src="simplepeer.min.js"></script>

peer.addStream(stream) call on the initiator peer doesn't raise peer.on('stream', ...) event on the other peer after successful data connection. When stream is passed through the initiator peer constructor, the event does get raised. I was expecting the same to happen when peer.addStream(stream) was called in situations where the stream is no yet known at peer construction time.

Also when inspecting the 'peer' object in the console, after the peer.addStream() is called, the "streams" prop, which is an array, still has a length of 0. No stream is added. Probably a regression bug.

@Bernard-Murphy
Copy link

I am having the same problem. Looking at #370 if a peer connection with no stream is initialized and the streams added later, we are supposed to pass constraints into our constructors:

var p1 = new Peer({initiator:true, offerConstraints: { offerToReceiveVideo: false, offerToReceiveAudio: false }) var p2 = new Peer({initiator:false, answerConstraints: { offerToReceiveVideo: false, offerToReceiveAudio: false })

Then once the new stream is to be added, before doing so the initiator must be signaled to accept audio/video using the setConstraints method:

var newConstraints = { offerToReceiveAudio: true, offerToReceiveVideo: true } signalingChannel.send('requestToChangeConstraints', newConstraints) this.peer.addStream(stream); signalingChannel.on('requestToChangeConstraints', (newConstraints) { this.peer.setConstraints(newConstraints); })

However when I do it, newConstraints, offerToReceiveAudio, and offerToReceiveVideo are all undefined. I'm thinking there is probably a new way of doing it, but can't tell from the readme and am unable to find more detailed documentation.

@Mill1995
Copy link

any updates on this one ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants