From ef6cb3248b62cc69d1081cff3c70cf27be4216a8 Mon Sep 17 00:00:00 2001 From: Ravi theja Date: Mon, 9 Dec 2024 15:27:12 +0530 Subject: [PATCH] fix: re-subscribe audio on decode error --- .../src/analytics/AnalyticsEventFactory.ts | 2 +- .../src/audio-sink-manager/AudioSinkManager.ts | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/hms-video-store/src/analytics/AnalyticsEventFactory.ts b/packages/hms-video-store/src/analytics/AnalyticsEventFactory.ts index 4197182456..6f0a278eb2 100644 --- a/packages/hms-video-store/src/analytics/AnalyticsEventFactory.ts +++ b/packages/hms-video-store/src/analytics/AnalyticsEventFactory.ts @@ -138,7 +138,7 @@ export default class AnalyticsEventFactory { static audioRecovered(message: string) { return new AnalyticsEvent({ name: 'audioRecovered', - level: AnalyticsEventLevel.VERBOSE, + level: AnalyticsEventLevel.INFO, properties: { message, }, diff --git a/packages/hms-video-store/src/audio-sink-manager/AudioSinkManager.ts b/packages/hms-video-store/src/audio-sink-manager/AudioSinkManager.ts index 9359b0b88e..e61f53a60f 100644 --- a/packages/hms-video-store/src/audio-sink-manager/AudioSinkManager.ts +++ b/packages/hms-video-store/src/audio-sink-manager/AudioSinkManager.ts @@ -9,7 +9,6 @@ import { HMSRemoteAudioTrack } from '../media/tracks'; import { HMSRemotePeer } from '../sdk/models/peer'; import { Store } from '../sdk/store'; import HMSLogger from '../utils/logger'; -import { sleep } from '../utils/timer-utils'; /** * Following are the errors thrown when autoplay is blocked in different browsers @@ -138,15 +137,11 @@ export class AudioSinkManager { ); this.eventBus.analytics.publish(AnalyticsEventFactory.audioPlaybackError(ex)); if (audioEl?.error?.code === MediaError.MEDIA_ERR_DECODE) { - // try to wait for main execution to complete first - this.removeAudioElement(audioEl, track); - await sleep(500); - await this.handleTrackAdd({ track, peer, callListener: false }); - if (!this.state.autoplayFailed) { - this.eventBus.analytics.publish( - AnalyticsEventFactory.audioRecovered('Audio recovered after media decode error'), - ); - } + await track.setVolume(0); + await track.setVolume(this.volume); + this.eventBus.analytics.publish( + AnalyticsEventFactory.audioRecovered('Audio recovered after media decode error'), + ); } }; track.setAudioElement(audioEl);