5

I am using webrtc-adapter v2.0.8, when I update my codes from

this.peerConnection.addStream(this.myStream);

to

this.myStream.getTracks().forEach(track => this.peerConnection.addTrack(track, this.myStream));

based on the demo. I got the error

getUserMedia: TypeError: _this.peerConnection.addTrack is not a function

in my browser (Chrome 56.0.2906.0 dev) console.

How can I use addTrack correctly? Thanks

2 Answers 2

5

UPDATE on July 15, 2019: Checked again today. Chrome 64 has support already.


Chrome has not supported addTrack yet:

https://bugs.chromium.org/p/chromium/issues/detail?id=705901

Also check Browser compatibility section here.

2
  • Unfortunately polyfilling addTrack on top of addStream is real hard.
    – jib
    Nov 24, 2016 at 20:00
  • any update on this i'am getting the error as op said when changed addstream to addtrack. Aug 23, 2019 at 5:08
0

Try: this.peer.addStream(this.myStream)

Note: peer object has a method 'addStream' which accepts stream object as a parameter

1
  • While this code may provide a solution to the question, it's better to add context as to why/how it works. This can help future users learn and eventually apply that knowledge to their own code. You are also likely to have positive-feedback/upvotes from users, when the code is explained.
    – Amit Verma
    Feb 17, 2021 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.