From 54cc3cae34009be824247b697b65c0c119a6bf94 Mon Sep 17 00:00:00 2001 From: raviteja83 Date: Mon, 20 May 2024 17:51:33 +0530 Subject: [PATCH] fix: test trial for local track --- .../src/media/tracks/HMSLocalVideoTrack.ts | 3 --- .../src/media/tracks/VideoElementManager.ts | 20 +++++++------------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts b/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts index 3e061c2f0a..013b08236c 100644 --- a/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts @@ -494,9 +494,6 @@ export class HMSLocalVideoTrack extends HMSVideoTrack { } else { this.nativeTrack.enabled = this.enabledStateBeforeBackground; this.replaceSenderTrack(this.nativeTrack); - if (this.nativeTrack.enabled) { - this.videoHandler.updateSinks(); - } } this.eventBus.localVideoEnabled.publish({ enabled: this.nativeTrack.enabled, track: this }); }; diff --git a/packages/hms-video-store/src/media/tracks/VideoElementManager.ts b/packages/hms-video-store/src/media/tracks/VideoElementManager.ts index ee2fe3c38a..1344a25450 100644 --- a/packages/hms-video-store/src/media/tracks/VideoElementManager.ts +++ b/packages/hms-video-store/src/media/tracks/VideoElementManager.ts @@ -29,6 +29,7 @@ export class VideoElementManager { for (const videoElement of this.videoElements) { if (this.track.enabled) { this.track.addSink(videoElement, requestLayer); + this.resumeVideoPlayback({ target: videoElement } as unknown as Event); } else { this.track.removeSink(videoElement, requestLayer); } @@ -84,20 +85,13 @@ export class VideoElementManager { } private resumeVideoPlayback = (e: Event) => { - console.trace('Resuming playback'); - if (!document.hidden && isMobile()) { + const element = e.target as HTMLVideoElement; + if (!document.hidden && isMobile() && element.paused) { setTimeout(() => { - const element = e.target as HTMLVideoElement; - if (element.paused) { - element.oncanplaythrough = () => { - console.log('element can play', this.track.peerId); - }; - console.log('element paused, try resuming', this.track.peerId); - this.track.addSink(element); - element.play().catch(err => { - HMSLogger.w(this.TAG, `Error resuming video playback for ${this.track.peerId} ${(err as Error).message}`); - }); - } + this.track.addSink(element); + element.play().catch(err => { + HMSLogger.w(this.TAG, `Error resuming video playback for ${this.track.peerId} ${(err as Error).message}`); + }); }, 0); } };