RTCMultiConnection
RTCMultiConnection copied to clipboard
replaceTrack while switching camera malfunctions.
So my application starts by using the front camera by default. Now to change to rear camera
navigator.mediaDevices.getUserMedia({
video: {
facingMode: 'environment'
}
}).then(function(backCamera) {
replaceTrack(backCamera);
});
is used. Note that: facingMode: 'application'
does not work.
Now to go back to front camera, the same thing is used just by changing facingMode: 'application'
to facingMode: 'user'
. On doing this the rear camera video disappears as expected, but the front camera does not show up.
Later on again toggling, the rear stream shows up, making the app stuck in rear view.
You need to stop the track on local video...
localCamera.srcObject.getTracks().forEach(function(track) { if (track.kind == 'video') { track.stop(); } });
localCamera.srcObject = backCamera;
and then make sure to play it. localCamera.play();
Can someone tell me how can I switch the cameras during the streams? front to rear or to another device camera?
Same here