From cb3224592d914a08038d3bf7b790c9a8e4b03f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Li=C5=A1ka?= Date: Wed, 23 Sep 2020 10:32:43 +0200 Subject: [PATCH] Refactoring mediaSessionInit variable --- app/js/elements/app.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/js/elements/app.js b/app/js/elements/app.js index c0f7d4b..aed9997 100644 --- a/app/js/elements/app.js +++ b/app/js/elements/app.js @@ -27,7 +27,6 @@ class App extends HTMLElement { await this._connect(); this.dispatchEvent(new CustomEvent("load")); - this.mediaSessionInit = false; this._initMediaHandler(); } @@ -83,11 +82,11 @@ class App extends HTMLElement { html.node("source", {src: 'https://raw.githubusercontent.com/anars/blank-audio/master/10-seconds-of-silence.mp3'}, '', audio); // Init event session (play audio) on click (because restrictions by web browsers) + let mediaSessionInit = false; window.addEventListener('click', () => { - if (!this.mediaSessionInit) { + if (mediaSessionInit) return; + mediaSessionInit = true; audio.play(); - this.mediaSessionInit = true; - } }); // mediaSession define metadata