Skip to content

Commit

Permalink
fix: re-subscribe audio on decode error
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Dec 9, 2024
1 parent dd14942 commit ef6cb32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ef6cb32

Please sign in to comment.