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.

addTrack and removeTrack not working

See original GitHub issue

i have tried to on/off video using addTrack and remove Track but not working

    `   document.getElementById('stopVedio').addEventListener('click', function () {
             peer1.removeTrack(stream.getVideoTracks()[0], stream);
            })
             document.getElementById('startVedio').addEventListener('click', function () {
                 peer1.addTrack(stream.getVideoTracks()[0] stream);
            })`

error : Track has been removed. You should enable/disable tracks that you want to re-add

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nazar-pccommented, Apr 18, 2020

@AidanNelson sounds like you want to use replaceTrack() API instead of adding/removing it. Also you can clone it and then it would appear as a new distinct track while being the same internally: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/clone

1reaction
nazar-pccommented, Apr 4, 2020

Indeed, you should better enable/disable tracks by changing enabled field instead of adding/removing them, which in turn requires renegotiation and is more nuanced than you may want it to be. Adding/removing should also work, but you will need to create a new track for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RTCPeerConnection.removeTrack() - Web APIs | MDN
The RTCPeerConnection.removeTrack() method tells the local end of the connection to stop sending media from the specified track, ...
Read more >
WebRTC problem with renegotiation (after addTrack ...
It looks like FireFox removeTrack() function works different then in other browsers, in FireFox removed sender stays in peerconnection object ...
Read more >
addTrack()/removeTrack/getSenders() and friends shipping in ...
removeTrack (): Senders are not reusable as per-spec, instead they are removed from getSenders(), blocked on transceiver work.
Read more >
[Objective-C] after removing a track from the local stream, pc ...
What steps will reproduce the problem? 1. Have a connected RTCPeerConnection with both audio and video and a local RTCMediaStream into it.
Read more >
Media Capture and Streams - W3C
The API is based on preliminary work done in the WHATWG. ... The addtrack and removetrack events use the MediaStreamTrackEvent interface.
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