From 0fad53b3e07237468e07921875eed61273b58f10 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 26 Oct 2023 23:32:50 -0700 Subject: [PATCH] video: keep time in src switches Signed-off-by: Varun Patil --- src/components/viewer/PsVideo.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/viewer/PsVideo.ts b/src/components/viewer/PsVideo.ts index 99228b96..428ffa5e 100644 --- a/src/components/viewer/PsVideo.ts +++ b/src/components/viewer/PsVideo.ts @@ -434,13 +434,13 @@ class VideoContentSetup { // Set the source to the original video if (isHLS) { - content.videojs.src(this.getDirectSrc(content)); + this.changeSourceKeepTime(content.videojs, this.getDirectSrc(content)); } return; } else { // Set source to HLS if (!isHLS) { - content.videojs.src(this.getHLSsrc(content)); + this.changeSourceKeepTime(content.videojs, this.getHLSsrc(content)); } } @@ -458,6 +458,13 @@ class VideoContentSetup { } } + changeSourceKeepTime(vidjs: Player, src: { src: string; type: string }) { + const time = vidjs.currentTime(); + vidjs.src(src); + vidjs.currentTime(time); + vidjs.play(); + } + onContentDestroy({ content }: PsVideoEvent) { this.destroyVideo(content); }