From d4c6a3b985ea56f730d11fb1c5f04a4fdc86e4dc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Dec 2017 14:01:34 +0100 Subject: Fix autoplay on non authenticated users --- client/src/app/videos/+video-watch/video-watch.component.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index e35b02f3f..3b5edc27a 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/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 + } } -- cgit v1.2.3