During a call or live broadcast, the audio that a web client is sending suddenly becomes silent, or the video goes black. After checking the log, you find that this occurred because the audio or video track stopped.
The most likely reasons why a track would stop are a loose or poor connection, or the device has been disconnected.
The applicable solution depends on the version of the Web SDK you are using.
The Web SDK v3.x does not support hot plugging. If you remove a device and reconnect it in, you must create a new stream. You can fix the issues of silent audio or black video due to stopped tracks as follows:
stream.on("audioTrackEnded")
and stream.on("videoTrackEnded")
events.stream.on("audioTrackEnded")
or stream.on("videoTrackEnded")
event, use a popup window to remind the end user to check whether the device is working or to reconnect the device.unpublish
to stop publishing the audio or video stream.createStream
to recreate the audio or video stream object.The Web SDK v4.x supports hot plugging. You can fix the issues of silent audio or black video due to stopped tracks as follows:
localTrack.on("track-ended")
event.localTrack.on("track-ended")
event, use a popup window to remind the end user to check whether the device is working or to reconnect the device.AgoraRTC.onMicrophoneChanged
or AgoraRTC.onCameraChanged
callback to get the device status. When the device is connected, call MicrophoneAudioTrack.setDevice
or CameraVideoTrack.setDevice
to use the device.