logo
On this page

How to handle black screen or no audio during live streaming on the Web platform?

2021-09-09
Products / Plugins:Video Call / Audio Call / Live streaming
Platform / Framework:Web

When the publishing end discovers that the local preview image suddenly goes black or the captured sound suddenly disappears, it is likely due to device loosening, poor contact, or disconnection, causing the audio or video track to stop.

When this problem occurs, you need to recreate the stream and republish after inserting the device. The specific steps are as follows:

  1. Listen to the device error callback event deviceError.
Note

SDK version 1.16.0 and above support the deviceError callback. If your current SDK version is lower than 1.16.0, please upgrade first.

const zg = zg = new ZegoExpressEngine(appID, server);
zg.on('deviceError', (errorCode, deviceName) => {
        // Prompt the user to confirm whether the device is working properly
});
  1. After the SDK triggers the deviceError event, prompt the user to confirm whether the device is working properly.
  • If the device is normal, end the operation.
  • If the device is abnormal, please reinsert the device and perform the following 3 steps.
  1. Call the stopPublishingStream interface to stop the current publishing.
zg.stopPublishingStream(streamID);
  1. Call the createStream interface to recreate the stream.
const localStream = await zg.createStream();
  1. Call the startPublishingStream interface to republish.
zg.startPublishingStream(streamID, localStream)

Previous

How to handle video zoom or black bars issue?

Next

How to handle audio echo issues?