Skip to main content
Version: 1.x.x

Audio Input Silence Events - Javascript

VideoSDK provides the audio-input-silence event to help you detect when a local participant's microphone is enabled but is not capturing any audio.

You can use this event to notify participants when their microphone may not be working as expected and guide them to check or switch their audio input device.

audio-input-silence

The audio-input-silence event is triggered when the local participant's microphone is enabled but stops capturing any audio signal. It is triggered again when audio capture resumes, with state set to resolved.

The event callback provides the following information:

ParameterTypeDescription
statestringIndicates whether silence was detected or resolved.
deviceLabelstringThe label of the audio input device, when available.
timestampnumberThe time at which the event occurred, in milliseconds since Unix epoch.

state

The state parameter can have one of the following values:

  • detected — The microphone is enabled, but no audio signal is being captured.
  • resolved — Audio input has resumed after silence was previously detected.

You can subscribe to this event using the on() method of the meeting object.

caution

The audio-input-silence event is not supported on Android mobile web browsers.

Important Considerations

Keep the following points in mind when handling this event:

  • Common reasons for audio input silence include:
    • A physical mute switch on a headset or microphone is enabled.
    • Another application is using the microphone.
    • The participant has answered a phone call while using a mobile browser.
    • The microphone or its driver is not functioning correctly.
    • A Bluetooth headset has switched its active connection to another device.
  • This event is sent only to the local participant. Other participants are not notified through this event.
  • Muting the microphone through your application does not trigger audio-input-silence.
  • If the participant turns their microphone off, no resolved event is generated because the microphone is no longer being monitored for input.
  • Audio input is checked periodically. As a result, there may be a short delay between the microphone becoming silent and the detected event being triggered.
  • A resolved event is triggered only when silence was previously detected and the microphone starts capturing audio again.

When state is detected, you can display a non-blocking notification to the local participant.

For example:

Others can't hear you. Your microphone isn't picking up any sound. Check your microphone or switch to another one.

You can improve the experience by:

  • Identifying the affected device. Use deviceLabel when available so the participant knows which microphone is affected.
  • Allowing the participant to switch microphones. Provide an option to select another audio input device. See the Change Input Device guide.
  • Keeping the warning visible until the issue is resolved. Remove the warning when a resolved event is received or when the participant turns off their microphone.
  • Avoiding automatic actions. Do not automatically mute the microphone, leave the meeting, or rejoin the meeting based only on this event. Let the participant decide how to resolve the issue.
  • Logging the event for troubleshooting. If you maintain client-side logs, recording deviceLabel, state, and timestamp can help diagnose audio input issues.

Example

The following example shows how to display a warning when the local microphone stops capturing audio:

// Assumes <p id="mic-silence-warning" hidden></p> in your HTML
const warningEl = document.getElementById("mic-silence-warning");

function showWarning(deviceName) {
warningEl.textContent = `Others can't hear you. ${deviceName} isn't picking up any sound. Check your microphone or switch to another one.`;
warningEl.hidden = false;
}

function hideWarning() {
warningEl.hidden = true;
}

meeting.on("audio-input-silence", ({ deviceLabel, state, timestamp }) => {
console.log("audio-input-silence", {
deviceLabel,
state,
timestamp,
});

if (state === "detected") {
showWarning(deviceLabel || "Your microphone");
} else if (state === "resolved") {
hideWarning();
}
});

meeting.localParticipant.on("stream-disabled", (stream) => {
// Clear the warning when the microphone is turned off
if (stream.kind === "audio") {
hideWarning();
}
});

In this example:

  • detected displays a warning to the local participant.
  • resolved removes the warning when audio input resumes.
  • Turning the microphone off also removes the warning, through the local participant's stream-disabled event.
  • deviceLabel is used to identify the microphone when the device label is available.

API Reference

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord