From 61b7559a6a209940e2a2985bf4bf4ce083446731 Mon Sep 17 00:00:00 2001 From: Yiran Duan Date: Mon, 20 Nov 2023 17:21:27 +0100 Subject: [PATCH] fixed #1214 Playback using link with t=0 does not work (#1231) Jump to 00:00 when set by parameter t = 0 --- web/ts/TUMLiveVjs.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/ts/TUMLiveVjs.ts b/web/ts/TUMLiveVjs.ts index 537a93c19..46d19369a 100644 --- a/web/ts/TUMLiveVjs.ts +++ b/web/ts/TUMLiveVjs.ts @@ -65,7 +65,7 @@ class PlayerSettings { let iOSReady; const t: number | undefined = +getQueryParam("t"); this.player.on("loadedmetadata", () => { - if (!isNaN(t) && t) { + if (!isNaN(t)) { this.player.currentTime(t); console.log(`⚫️ jump to: ${t}`); } @@ -73,7 +73,7 @@ class PlayerSettings { if (videojs.browser.IS_IOS) { this.player.on("canplaythrough", () => { // Can be executed multiple times during playback - if (!iOSReady && t) { + if (!iOSReady) { this.player.currentTime(t); iOSReady = true; } @@ -323,11 +323,12 @@ export const watchProgress = function (streamID: number, lastProgress: number) { let iOSReady = false; let intervalMillis = 10000; let jumpTo: number; + const tParam = +getQueryParam("t"); // Fetch the user's video progress from the database and set the time in the player players[j].on("loadedmetadata", () => { duration = players[j].duration(); - jumpTo = +getQueryParam("t") || lastProgress * duration; + jumpTo = isNaN(tParam) ? lastProgress * duration : tParam; players[j].currentTime(jumpTo); });