addTrack and removeTrack not working
See original GitHub issuei 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:
- Created 3 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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
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.