Error on peer.removeStream from multiple connections
- Dominant language
- JavaScript
- Stars
- 7.8k
- Forks
- 983
- PR merge metrics
- No merged PRs in 30d
Description
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`.
```javascript
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:
```javascript
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](https://github.com/feross/simple-peer/issues/304#issuecomment-631573126). Is there other way to solve this problem?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.