Original publication date: April 26, 2022
Added
-
Mobile browser support.
-
Support for multiple videos (3 others + 1 self) on Chromium browsers without
SharedArrayBuffer
. Set the value ofenforceMultipleVideos
totrue
in theinit
method to enable this feature.
Fixed
-
Audio issues on Safari browser.
-
Unexpected failover when leaving or ending a session on Safari (related to the
NSURLSession
WebSocketexperimental feature). -
Issue of improperly clearing all
sessionStorage
when leaving the session. -
An edge case issue with session idle timeouts and command channel.
Safari limitation
-
There are two limitations to be aware of when using audio on Safari:
-
You must call
startAudio
after the audio encoding or decoding web workers have been initialized. -
Audio cannot start before users interact with the page. Unlike other browsers, Safari does not inform the SDK when this happens. This makes it impossible to defer incorrectly-timed
startAudio
calls until after user interaction.
-
-
Therefore, logic similar to below must be added to ensure that the web workers have been initialized correctly:
let audioDecode, audioEncode; client.on("media-sdk-change", (payload) => { const { action, type, result } = payload; if (type === "audio" && result === "success") { // encode for sending audio stream (talk) if (action === "encode") { audioEncode = true; } // decode for receiving audio stream (hear) else if (action === "decode") { audioDecode = true; } } }); // click event callback joinAudioButton.addEventListener("click",event=>{ if(audioEncode && audioDecode){ stream.startAudio(); } })
-
And when calling
startAudio
:
if(audioEncode && audioDecode){ stream.startAudio(); }
-
-
If calling
startAudio
on button click, no other checks are needed. If calling in a scenario where user interaction isn’t guaranteed (for example, after joining a meeting and web workers have initialized), a flag can be set to properly check the user interaction status:let audioDecode, audioEncode; client.on("media-sdk-change", (payload) => { const { action, type, result } = payload; if (type === "audio" && result === "success") { if (action === "encode") { audioEncode = true; } else if (action === "decode") { audioDecode = true; } if (audioDecode && audioEncode) { try { // start audio automatically in Safari stream.startAudio({ autoStartAudioInSafari: true }); } catch (err) { console.warn(err); } } } }); // Here you can catch the event client.on("auto-play-audio-failed",()=>{ console.log("Auto join audio failed, click anywhere on the page to automatically join the audio ") })