Issue Description:
Users are experiencing video freezes during a session, which are related to autoplay errors in the Agora SDK.
Platform/SDK:
AgoraRTC SDK v4.23.4 running on Web.
Error Message (optional):
AgoraRTC_N_v4.23.4.js:5 12:41:47:245 Agora-SDK [INFO]: detect audio element autoplay failed
AgoraRTC_N_v4.23.4.js:5 12:41:47:245 Agora-SDK [INFO]: detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web
AgoraRTC_N_v4.23.4.js:5 12:41:47:245 Agora-SDK [WARNING]: We have detected a media autoplay failed event, and found out that you haven't implemented AgoraRTC.onAutoplayFailed callback yet.
Step by Step Solution:
1. Implement the Autoplay Callback:
- Access your AgoraRTC project settings where the SDK is integrated.
- Ensure to implement the AgoraRTC.onAutoplayFailed callback function. This is necessary to handle cases where media fails to play automatically. Here's a snippet:
javascript
AgoraRTC.onAutoplayFailed(() => {
// Prompt the user to interact with the page if needed to start the video/audio
});
2. Update Agora Documentation:
- Visit the official Agora Autoplay policy page for detailed guidance on setting up autoplay configurations properly for your project.
3. Ensure Stream Stability for Users:
- Check for frequent joins and disconnects in user logs. Such activity may cause instability. Ensure a stable network connection for all participants.
4. Test the Implementation:
- After making the above changes, conduct a test session to verify that video playback initiates smoothly without requiring user interaction.
Root Cause:
The video freezes are due to the browser's autoplay policy preventing the automatic playback of media without user interaction. The issue is compounded when the AgoraRTC.onAutoplayFailed callback is not implemented to handle such events.
Prevention/Best Practice (optional):
- Regularly update the Agora SDK to benefit from the latest features and fixes.
- Educate users about browser restrictions on autoplay to manage their expectations.
Corresponding Document/Link (optional):
- Agora Autoplay policy documentation for detailed technical instructions on handling autoplay issues on web browsers.