0

I am trying to understand if there is a way to know if a peer has already been hooked up with a specific audio and/or video track or not because before peer.addTrack(track) I want to make sure a track will not be added twice to the same peer.

Hypothesis
  • 1,208
  • 3
  • 17
  • 43

1 Answers1

0

You could try removing that track before adding, if you suspect a duplicate: https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/removeTrack

Or check track senders for duplicates: https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getSenders

PS: Usually there's 2 track events that are not duplicates (audio + video).

TopReseller
  • 623
  • 4
  • 6
  • Actually since I have multiple tracks I cannot remove a track I just need to make sure if it is added or not. – Hypothesis Aug 03 '21 at 19:56