Add autoplay parameter in embed
authorChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 08:34:40 +0000 (10:34 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 09:11:15 +0000 (11:11 +0200)
client/src/standalone/videos/embed.ts

index 964ec56f3dabccbc21ec0969f0ba1f15da92fba8..08f2955cfe0184997de402d0420eb06410db1186 100644 (file)
@@ -24,9 +24,18 @@ loadVideoInfo(videoId)
     const previewUrl = window.location.origin + videoInfo.previewPath
     videoElement.poster = previewUrl
 
+    let autoplay = false
+
+    try {
+      let params = new URL(window.location.toString()).searchParams
+      autoplay = params.has('autoplay') && (params.get('autoplay') === '1' || params.get('autoplay') === 'true')
+    } catch (err) {
+      console.error('Cannot get params from URL.', err)
+    }
+
     const videojsOptions = {
       controls: true,
-      autoplay: false,
+      autoplay,
       inactivityTimeout: 500,
       plugins: {
         peertube: {