RTCMultiConnection icon indicating copy to clipboard operation
RTCMultiConnection copied to clipboard

replaceTrack while switching camera malfunctions.

Open BasilVictor opened this issue 4 years ago • 3 comments

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.

BasilVictor avatar Apr 24 '20 22:04 BasilVictor

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();

umerfarooqkit avatar May 01 '20 17:05 umerfarooqkit

Can someone tell me how can I switch the cameras during the streams? front to rear or to another device camera?

chai2 avatar Sep 21 '20 07:09 chai2

Same here

Careprod-Technologies avatar Aug 04 '21 14:08 Careprod-Technologies