question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event for when stream is removed?

See original GitHub issue

We can call peer.removeStream(), and this appears to work fine. I’m curious though if on the receiving end, the peer has some sort of event for when this happens? Or, is there some sort of event on the stream where we know that it’s totally done? (Or, is this just looping through tracks and removing them one-by-one under the hood, in which case we should use the removetrack event on the MediaStream?)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
t-mullencommented, Feb 5, 2020

Closing since the mute event is the spec-compliant way to detect track removal. We support this in simple-peer already.

1reaction
t-mullencommented, Feb 5, 2020

@kishorenc This used to work, but you’re right it’s not in the specification. It seems browsers have fixed this behaviour.

It looks like the removetrack event has also been removed from the spec. The new behaviour is to fire a mute event on the remote track.

When the other peer stops sending a track in this manner, the track is removed from any remote MediaStreams that were initially revealed in the track event, and if the MediaStreamTrack is not already muted, a mute event is fired at the track.

peer.addTrack(track, stream)
peer.removeTrack(track, stream)
peer.on('track', (track, stream) => {
  track.addEventListener('mute', () => {
    // track was removed by remote
  })
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

RTCPeerConnection: removestream event - Web APIs | MDN
The obsolete removestream event was sent to an RTCPeerConnection to inform it that a MediaStream had been removed from the connection. You can ......
Read more >
WebRTC: how to detect when a stream or track gets removed ...
On this happening, our receiver.track would be unmuted again and reinserted into the stream(s), firing the addtrack events on the stream(s).
Read more >
Event streams - EventStoreDB Documentation
When you delete a stream, you can use either a soft delete or hard delete. When a stream is soft-deleted, all events from...
Read more >
MediaStream: removetrack event - Web APIs
object has been removed from a MediaStream ... Event handler property, onremovetrack ... let stream = new MediaStream(); stream.onremovetrack = (event) ...
Read more >
Stream | Node.js v19.3.0 Documentation
Once all currently buffered chunks are drained (accepted for delivery by the operating system), the 'drain' event will be emitted. Once write() returns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found