From f37bad639b36d35c29a464dc52123a1e7c9cd28a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 5 Apr 2018 17:06:59 +0200 Subject: Add ability to set a start time --- client/src/standalone/videos/embed.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'client/src/standalone/videos') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 1efecd3f3..a99bc586f 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -23,10 +23,15 @@ loadVideoInfo(videoId) const videoElement = document.getElementById(videoContainerId) as HTMLVideoElement let autoplay = false + let startTime = 0 try { let params = new URL(window.location.toString()).searchParams autoplay = params.has('autoplay') && (params.get('autoplay') === '1' || params.get('autoplay') === 'true') + + const startTimeParamString = params.get('start') + const startTimeParamNumber = parseInt(startTimeParamString, 10) + if (isNaN(startTimeParamNumber) === false) startTime = startTimeParamNumber } catch (err) { console.error('Cannot get params from URL.', err) } @@ -40,7 +45,8 @@ loadVideoInfo(videoId) videoDuration: videoInfo.duration, enableHotkeys: true, peertubeLink: true, - poster: window.location.origin + videoInfo.previewPath + poster: window.location.origin + videoInfo.previewPath, + startTime }) videojs(videoContainerId, videojsOptions, function () { const player = this -- cgit v1.2.3