From 6554367ba3e509ee15242c30e6b83e83c1a96169 Mon Sep 17 00:00:00 2001 From: raviteja83 Date: Fri, 17 May 2024 12:02:18 +0530 Subject: [PATCH] fix: try indefinitely until played --- .../src/media/tracks/VideoElementManager.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/hms-video-store/src/media/tracks/VideoElementManager.ts b/packages/hms-video-store/src/media/tracks/VideoElementManager.ts index c808b5c964..53d64b6206 100644 --- a/packages/hms-video-store/src/media/tracks/VideoElementManager.ts +++ b/packages/hms-video-store/src/media/tracks/VideoElementManager.ts @@ -6,6 +6,7 @@ import { HMSIntersectionObserver } from '../../utils/intersection-observer'; import HMSLogger from '../../utils/logger'; import { HMSResizeObserver } from '../../utils/resize-observer'; import { isBrowser } from '../../utils/support'; +import { sleep } from '../../utils/timer-utils'; /** * This class is to manager video elements for video tracks. @@ -87,10 +88,11 @@ export class VideoElementManager { if (document.visibilityState === 'visible') { for (const element of this.videoElements) { if (element.paused) { - element.oncanplay = async () => { - console.log('playing video element', this.track.trackId); + while (element.paused) { + sleep(1000); + console.log('playing video element'); await element.play(); - }; + } } } }