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 Is not a function

See original GitHub issue

I am using the react-native-webrtc ^1.84.1 but its throwing error addTrack is not a function when I try to add track with the peer connection object. My code is below

 const connectionBuffer = new RTCPeerConnection(config);

        stream.getTracks.forEach(track =>
          connectionBuffer.addTrack(track, stream),
        );

Complete code of the page can be found here https://github.com/jdmg94/react-native-webrtc-example/blob/master/App.js I am using this example

Expected behavior

Expected it to connect and start streaming

Observerd behavior

But its throwing error saying addTrack is not a function

Steps to reproduce the problem

https://github.com/jdmg94/react-native-webrtc-example/blob/master/App.js I am using this repo example as my base,

Platform information

  • React Native version:0.63.2
  • Plugin version:^1.84.1
  • OS: Android
  • OS version:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
saghulcommented, Nov 6, 2020

PeerConncetion…addTrack is not implemented.

2reactions
yashodhanmohancommented, Nov 19, 2020

@ajitdas123 @pdias94 As @saghul mentioned, RTCPeerConnection.addTrack(..) has not been implemented yet as can be seen in this file. You can however add a stream to the peer connection (using RTCPeerConnection.addStream(..)) and add the tracks to the stream (using MediaStream.addTrack(..))


const connectionBuffer = new RTCPeerConnection(config);
connectionBuffer.addStream(stream);
/** 

You can skip this since from your example it appears that
the stream already contains the tracks

stream.getTracks.forEach(track =>
    connectionBuffer.addTrack(track, stream),
);

*/

@saghul am I correct in my interpretation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: peerConnection.addstream is not a ...
I have tried to add the stream in the following way. function startPeerConnection(stream) { var configuration = { // Uncomment this code to...
Read more >
RTCPeerConnection.addTrack() - Web APIs | MDN
The RTCPeerConnection method addTrack() adds a new media track to the set of ... Only tracks are sent from one peer to another,...
Read more >
this._pc.addTrack is not a function simplepeer or simple-peer
addTrack is not a function simplepeer or simple-peer help, interview question, Android,Javascript, React, React Native, Php, Salesforce.
Read more >
RTCPeerConnection addTrack missing in Chrome (version
addTrack is not a function (pc = RTCPeerConnection), does someone know any workaround? I'm using the adapter.js from -> https://github.com/ ...
Read more >
Developers - addTrack Is not a function - - Bountysource
I am using the react-native-webrtc ^1.84.1 but its throwing error addTrack is not a function when I try to add track with the...
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