From 368e4d7f7c7305a1a1fbc55e05046d8497b0bb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 28 Nov 2021 14:33:52 +0100 Subject: [PATCH] ix autoplay unmute. --- client/src/components/video.vue | 9 ++++++--- client/src/main.ts | 9 --------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/client/src/components/video.vue b/client/src/components/video.vue index afe5d2d..a246631 100644 --- a/client/src/components/video.vue +++ b/client/src/components/video.vue @@ -339,10 +339,13 @@ @Watch('muted') onMutedChanged(muted: boolean) { - if (this._video) { + if (this._video && this._video.muted != muted) { this._video.muted = muted this.startsMuted = muted - if (!muted) this.mutedOverlay = false + } + + if (!muted) { + this.mutedOverlay = false } } @@ -392,9 +395,9 @@ this._video.addEventListener('canplaythrough', () => { this.$accessor.video.setPlayable(true) if (this.autoplay) { + // start as muted due to restrictive browsers autoplay policy if (this.startsMuted && (!document.hasFocus() || !this.$accessor.active)) { this.$accessor.video.setMuted(true) - this._video.muted = true } this.$nextTick(() => { diff --git a/client/src/main.ts b/client/src/main.ts index ffcb2a9..fd89014 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -29,15 +29,6 @@ new Vue({ store, render: (h) => h(app), created() { - const click = () => { - this.$accessor.setActive() - if (this.$accessor.settings.autoplay && this.$accessor.video.playing) { - this.$accessor.video.setMuted(false) - } - window.removeEventListener('click', click, false) - } - window.addEventListener('click', click, false) - this.$client.init(this) this.$accessor.initialise() },