Skip to content

Commit

Permalink
fix: minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed Dec 7, 2024
1 parent 0737250 commit 3552fb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 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 @@ -5,6 +5,7 @@ import { ErrorFactory } from '../error/ErrorFactory';
import { HMSAction } from '../error/HMSAction';
import { EventBus } from '../events/EventBus';
import { HMSDeviceChangeEvent, HMSTrackUpdate, HMSUpdateListener } from '../interfaces';
import { HMSAudioContextHandler } from '../internal';
import { HMSRemoteAudioTrack } from '../media/tracks';
import { HMSRemotePeer } from '../sdk/models/peer';
import { Store } from '../sdk/store';
Expand Down Expand Up @@ -72,7 +73,8 @@ export class AudioSinkManager {
*/
async unblockAutoplay() {
if (this.autoPausedTracks.size > 0) {
this.unpauseAudioTracks();
await this.unpauseAudioTracks();
await HMSAudioContextHandler.resumeContext();
}
}

Expand Down Expand Up @@ -152,21 +154,21 @@ export class AudioSinkManager {
if (audioEl?.error?.code === MediaError.MEDIA_ERR_DECODE) {
// try to wait for main execution to complete first
this.removeAudioElement(audioEl, track);
console.error(audioEl);
await sleep(500);
console.error('retrying for trackId', track.trackId);
HMSLogger.d(this.TAG, 'retrying for trackId', track.trackId, HMSAudioContextHandler.getAudioContext().state);
await HMSAudioContextHandler.resumeContext();
await this.handleTrackAdd({ track, peer, callListener: false });
alert('Audio playback error');
console.error(
HMSLogger.d(
this.TAG,
'after retry for trackId',
track.trackId,
'autoplayState',
this.state.autoplayFailed,
'autopausedTracks',
this.autoPausedTracks.values(),
);
if (!this.state.autoplayFailed) {
console.error('audioRecoveredEvent sent', track.trackId);
if (!this.state.autoplayFailed && this.state.autoplayCheckPromise) {
HMSLogger.d(this.TAG, 'audioRecoveredEvent sent', track.trackId);
this.eventBus.analytics.publish(
AnalyticsEventFactory.audioRecovered('Audio recovered after media decode error'),
);
Expand Down

0 comments on commit 3552fb0

Please sign in to comment.