AgoraIO / agora-rtc-web

9 stars 2 forks source link

"facingMode: environment" Not Working in agora-rtc-web #1

Closed Samiddha99 closed 1 year ago

Samiddha99 commented 1 year ago

Setting facingMode to environment in createMicrophoneAndCameraTracks() for CameraVideoTrackInitConfig, not switching the camera to back camera in mobile, it still using front camera.

I have added the below configuration in my code:

import IAgoraRTC, {
  createMicrophoneAndCameraTracks,
  MicrophoneAudioTrackInitConfig,
  CameraVideoTrackInitConfig,
} from "agora-rtc-react";

var audioTrackConfig:MicrophoneAudioTrackInitConfig = {
  AEC: true, //Enable acoustic echo cancellation
  AGC: true, // Enable audio gain control
  ANS: true, // Enable automatic noise suppression
}
var videoTrackConfig:CameraVideoTrackInitConfig = {
  facingMode: 'environment' // front or rear camera
}

const useMicrophoneAndCameraTracks = createMicrophoneAndCameraTracks(audioTrackConfig, videoTrackConfig);
const { ready, tracks } = useMicrophoneAndCameraTracks();
simo-an commented 1 year ago

It does not work on all models of mobile ?

Please provide the mobile model in details !

And try the following code at the mobile to check whether the front and rear camera is fine!

const stream1 = await navigator.mediaDevices.getUserMedia({video: {facingMode: "environment"}});
const video1 = document.createElement('video');
const stream2 = await navigator.mediaDevices.getUserMedia({video: {facingMode: "user"}});
const video2 = document.createElement('video');

document.body.appendChild(video1);
document.body.appendChild(video2);

video1.srcObject = stream1;
video2.srcObject = stream2;

video1.play();
video2.play();
simo-an commented 1 year ago

the issue will be closed due to no further reply.