]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/standalone/videos/embed.ts
Add ability to set a start time
[github/Chocobozzz/PeerTube.git] / client / src / standalone / videos / embed.ts
index 1efecd3f3dbdb7c8fe3e1fbc11f9938571ae73c8..a99bc586fd71de6dd4251684d05e31f82822b46d 100644 (file)
@@ -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