Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
Agora can not switch the camera getting : Cannot read properties of undefined (reading 'deviceId')

I am trying to use Agora.io. Everything was working as it should. Until I add switching between cameras. I'm trying to switch between cameras thanks to the code below. But the problem is that I get this error: Uncaught TypeError: Cannot read properties of undefined (reading 'deviceId')

The error line is in the changeStreamSource() :

deviceId = devices.cameras[deviceIndex].deviceId;

Can you guide me on this?

function changeStreamSource (deviceIndex, deviceType) {
  console.log('Switching stream sources for: ' + deviceType); 
  var deviceId;
  var existingStream = false; 
  if (deviceType === "video") {    
    deviceId = devices.cameras[deviceIndex].deviceId; 
  }  
   
  localStreams.camera.stream.switchDevice(deviceType, deviceId, function(){  
    console.log('successfully switched to new device with id: ' + JSON.stringify(deviceId));
    // set the active device ids
    if(deviceType === "audio") {
      localStreams.camera.micId = deviceId;
    } else if (deviceType === "video") {
      localStreams.camera.camId = deviceId;
    } else {
      console.log("unable to determine deviceType: " + deviceType);
    }
  }, function(){
    console.log('failed to switch to new device with id: ' + JSON.stringify(deviceId));
  });
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

devices isn't defined in your code. You can get a list of devices using AgoraRTC.getDevices method.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda