Bläddra i källkod

Fix autoplay on non authenticated users

Chocobozzz 6 år sedan
förälder
incheckning
d4c6a3b985
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10 2
      client/src/app/videos/+video-watch/video-watch.component.ts

+ 10 - 2
client/src/app/videos/+video-watch/video-watch.component.ts

@@ -290,12 +290,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
           const videojsOptions = {
             controls: true,
-            autoplay: this.user.autoPlayVideo,
+            autoplay: this.isAutoplay(),
             plugins: {
               peertube: {
                 videoFiles: this.video.files,
                 playerElement: this.playerElement,
-                autoplay: this.user.autoPlayVideo,
+                autoplay: this.isAutoplay(),
                 peerTubeLink: false
               }
             }
@@ -373,4 +373,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
     }, viewTimeoutSeconds * 1000)
   }
+
+  private isAutoplay () {
+    // True by default
+    if (!this.user) return true
+
+    // Be sure the autoPlay is set to false
+    return this.user.autoPlayVideo !== false
+  }
 }