hanc-webrtc-widgets 2.3.1 → 2.3.2

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.
@@ -17312,53 +17312,54 @@ class wd extends EventTarget {
17312
17312
  const { token: r, url: a, room_name: o, user_identity: c } = await s.json();
17313
17313
  this.roomName = o, this.userIdentity = c, this.reconnectAttempts = 0, this.wasConnectedBeforeHidden = !1, await this.connectWithTimeout(n, a, r, 2e4);
17314
17314
  try {
17315
- n.startAudio().then(() => {
17316
- console.log("[LiveKit] Audio playback started");
17317
- }).catch((l) => {
17318
- console.warn("[LiveKit] Failed to start audio:", l);
17319
- });
17315
+ await Promise.race([
17316
+ n.startAudio(),
17317
+ new Promise((l) => setTimeout(l, 3e3))
17318
+ ]), console.log("[LiveKit] Audio playback started");
17320
17319
  } catch (l) {
17321
17320
  console.warn("[LiveKit] Failed to start audio:", l);
17322
17321
  }
17323
- this.updateStatus("connected"), this.isReady = !0, this.scheduleTimer(async () => {
17324
- if (this.isDestroyed || !this.room || this.room.state !== "connected") {
17325
- t.then((d) => {
17326
- d && d.getTracks().forEach((u) => u.stop());
17327
- });
17328
- return;
17329
- }
17330
- const l = await Promise.race([
17331
- t,
17332
- new Promise((d) => setTimeout(() => d(null), 1500))
17333
- ]);
17334
- if (l)
17335
- try {
17336
- await n.localParticipant.setMicrophoneEnabled(!0, {
17337
- echoCancellation: !0,
17338
- noiseSuppression: !0,
17339
- autoGainControl: !this.isAppleDevice
17340
- }), this.microphoneEnabled = !0, this.dispatchEvent(new CustomEvent("microphone-enabled")), l.getTracks().forEach((d) => d.stop()), this.scheduleTimer(() => {
17341
- if (!(this.isDestroyed || !this.room || this.room.state !== "connected"))
17342
- try {
17343
- const d = Array.from(n.localParticipant.audioTrackPublications.values()).find((u) => u.kind === "audio");
17344
- if (d != null && d.track) {
17345
- const u = d.track.mediaStreamTrack;
17346
- u && this.dispatchEvent(
17347
- new CustomEvent("local-audio-track", {
17348
- detail: u
17349
- })
17350
- );
17351
- }
17352
- } catch (d) {
17353
- console.warn("[LiveKit] Error getting local audio track:", d);
17354
- }
17355
- }, 100);
17356
- } catch (d) {
17357
- console.warn("Could not enable microphone on connect:", d), this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17322
+ this.updateStatus("connected"), this.isReady = !0, requestAnimationFrame(() => {
17323
+ this.scheduleTimer(async () => {
17324
+ if (this.isDestroyed || !this.room || this.room.state !== "connected") {
17325
+ t.then((d) => {
17326
+ d && d.getTracks().forEach((u) => u.stop());
17327
+ });
17328
+ return;
17358
17329
  }
17359
- else
17360
- this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17361
- }, 0), this.dispatchEvent(
17330
+ const l = await Promise.race([
17331
+ t,
17332
+ new Promise((d) => setTimeout(() => d(null), 5e3))
17333
+ ]);
17334
+ if (l)
17335
+ try {
17336
+ await n.localParticipant.setMicrophoneEnabled(!0, {
17337
+ echoCancellation: !0,
17338
+ noiseSuppression: !0,
17339
+ autoGainControl: !this.isAppleDevice
17340
+ }), this.microphoneEnabled = !0, this.dispatchEvent(new CustomEvent("microphone-enabled")), l.getTracks().forEach((d) => d.stop()), this.scheduleTimer(() => {
17341
+ if (!(this.isDestroyed || !this.room || this.room.state !== "connected"))
17342
+ try {
17343
+ const d = Array.from(n.localParticipant.audioTrackPublications.values()).find((u) => u.kind === "audio");
17344
+ if (d != null && d.track) {
17345
+ const u = d.track.mediaStreamTrack;
17346
+ u && this.dispatchEvent(
17347
+ new CustomEvent("local-audio-track", {
17348
+ detail: u
17349
+ })
17350
+ );
17351
+ }
17352
+ } catch (d) {
17353
+ console.warn("[LiveKit] Error getting local audio track:", d);
17354
+ }
17355
+ }, 100);
17356
+ } catch (d) {
17357
+ console.warn("Could not enable microphone on connect:", d), this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17358
+ }
17359
+ else
17360
+ this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17361
+ }, 50);
17362
+ }), this.dispatchEvent(
17362
17363
  new CustomEvent("room-connected", {
17363
17364
  detail: { roomName: o, identity: c }
17364
17365
  })