Estoy agregando una clase de 'habla' para mostrar un borde cuando el usuario está hablando. Cuando hablo, el código funciona:
if (options.uid == volume.uid && volume.level > volumeLevel) { document.getElementById(options.uid).classList.add("speaking"); }else if (options.uid == volume.uid && volume.level < volumeLevel) { document.getElementById(options.uid).classList.remove("speaking"); }Pero otros usuarios en otras páginas obtienen un error: TypeError: no se puede leer la propiedad 'classList' de null
if(options.uid != volume.uid && volume.level > volumeLevel) { document.getElementById(options.uid).classList.add("speaking"); }else if (options.uid != volume.uid && volume.level < volumeLevel) { document.getElementById(options.uid).classList.remove("speaking"); }código completo
var volumeLevel=15; rtc.on("volume-indicator", volumes => { volumes.forEach((volume) => { if (options.uid == volume.uid && volume.level > volumeLevel) { document.getElementById(options.uid).classList.add("speaking"); }else if (options.uid == volume.uid && volume.level < volumeLevel) { document.getElementById(options.uid).classList.remove("speaking"); } if (options.uid != volume.uid && volume.level > volumeLevel) { document.getElementById(options.uid).classList.add("speaking"); }else if (options.uid != volume.uid && volume.level < volumeLevel) { document.getElementById(options.uid).classList.remove("speaking"); } }); })Parece que options.uid no está en el DOM si document.getElementById() devuelve null