livekit-client 2.9.8 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -140,10 +140,16 @@ export function getNewAudioContext(): AudioContext | void {
140
140
  typeof window !== 'undefined' &&
141
141
  window.document?.body
142
142
  ) {
143
- const handleResume = () => {
144
- audioContext.resume().then(() => {
145
- window.document.body?.removeEventListener('click', handleResume);
146
- });
143
+ const handleResume = async () => {
144
+ try {
145
+ if (audioContext.state === 'suspended') {
146
+ await audioContext.resume();
147
+ }
148
+ } catch (e) {
149
+ console.warn('Error trying to auto-resume audio context', e);
150
+ }
151
+
152
+ window.document.body?.removeEventListener('click', handleResume);
147
153
  };
148
154
  window.document.body.addEventListener('click', handleResume);
149
155
  }