Error on peer.removeStream from multiple connections
I have problem with removing stream from multiple connections. I have multiple connections from which I want to remove same stream / track.
When all connections share the same stream and I try to use peer.removeStream(stream) method on each connection I receive error: e.getTracks is not a function.
for(let peer of peers) {
peer.removeStream(stream);
}
I've noticed in simple-peer code that peer.removeStream(stream) method is removing tracks from stream, so I started to create separate streams for each connection:
for(let peer of peers) {
let newStream = new MediaStream(stream);
peer.addStream(newStream);
}
Unfortunatelly in this case on peer.removeStream(stream) I receive error: Uncaught Error: Cannot remove track that was never added..
It only happens on removing stream/streams which share the same track form 2 or more connections.
Removing track with stream.removeTrack(track), seems to not firing any event on receiver side (most likely because of transceivers).
How can I remove track from multiple connections in a way that fire ended or removetrack event or force renegotiation?
@ted-piotrowski suggested to send event by data channel here. Is there other way to solve this problem?
+1