Skip to content

Commit

Permalink
fix: audio not audible when audio decode error occurs (#3289)
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 authored and raviteja83 committed Oct 9, 2024
1 parent e955d49 commit bba244b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/hms-video-store/src/analytics/AnalyticsEventFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ export default class AnalyticsEventFactory {
});
}

static audioRecovered(message: string) {
return new AnalyticsEvent({
name: 'audioRecovered',
level: AnalyticsEventLevel.VERBOSE,
properties: {
message,
},
});
}

static deviceChange({
isUserSelection,
selection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,19 @@ 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'),
);
}
}
};
track.setAudioElement(audioEl);
track.setVolume(this.volume);
await track.setVolume(this.volume);
HMSLogger.d(this.TAG, 'Audio track added', `${track}`);
this.init(); // call to create sink element if not already created
this.audioSink?.append(audioEl);
Expand Down

0 comments on commit bba244b

Please sign in to comment.