I want to add an audio stream obtained via getusermedia () to the canvas stream and send it to the remote peer... So I looked up, and there was addTrack (). But addTrack () does not seem to work properly. I am running on chrome.
var audioTracks;
navigator.getUserMedia({ "audio": true, "video": false }, function (stream)
{
audioTracks = stream.getAudioTracks()[0];
}, function(error) { console.log(error);});
.
.
.
var sharestream = canvas2.captureStream(25); // 25 FPS
peerConn.addTrack(audioTracks,sharestream);
peerConn.addStream(sharestream);
It's part of my code. What's wrong? My webrtc full source code works fine, but it does not work with addTrack ().
Updated on 10-29-2018 to replace
getAudioTracks
withgetTracks
: