From 878d7ffc64e656acc2ce51973241becf4b070411 Mon Sep 17 00:00:00 2001 From: meandaD Date: Wed, 8 Nov 2023 16:22:09 +0100 Subject: [PATCH 1/2] fixed #1214 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..56fd018b4 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; + let 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); }); From f76f9cacfdba754658aeb75d4a594aa9c6ef2aff Mon Sep 17 00:00:00 2001 From: meandaD Date: Wed, 8 Nov 2023 16:27:07 +0100 Subject: [PATCH 2/2] fix ESLint errors --- web/ts/TUMLiveVjs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/ts/TUMLiveVjs.ts b/web/ts/TUMLiveVjs.ts index 56fd018b4..46d19369a 100644 --- a/web/ts/TUMLiveVjs.ts +++ b/web/ts/TUMLiveVjs.ts @@ -323,12 +323,12 @@ export const watchProgress = function (streamID: number, lastProgress: number) { let iOSReady = false; let intervalMillis = 10000; let jumpTo: number; - let tParam = +getQueryParam("t"); + 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 = isNaN(tParam) ? (lastProgress * duration) : tParam; + jumpTo = isNaN(tParam) ? lastProgress * duration : tParam; players[j].currentTime(jumpTo); });