Search code examples
javascriptwebrtcjanus

How to turn off laptop light when using only microphone in video conference?


I am developing a video conferencing solution using a media server called janus. It transmits the microphone and camera using WebRTC. I don't want the laptop light to come on when only the mic is on. However, like when only the camera is on, the indicator light comes on when only the microphone is on. How do I solve this?


Solution

  • I assume by WebRTC, you are getting user's mic/webcam through navigator.mediaDevices.getUserMedia. I believe the camera light is controlled by the laptop driver and you cannot control it. However, if you do not need video, you can set the constraint parameter:

    // Set video to false so camera is not activated
    const constraints = { audio: true, video: false }
    const stream = await navigator.mediaDevices.getUserMedia(constraints);
    

    This way hopefully camera is not activated and the laptop light won't light up.

    If you want to disable video after requested, try stopping the video track. Hopefully it would stop using the camera and the light would turn off:

    stream.getVideoTracks().forEach(track => track.stop());