Refactoring mediaSessionInit variable
This commit is contained in:
parent
a440f79f42
commit
cb3224592d
1 changed files with 3 additions and 4 deletions
|
@ -27,7 +27,6 @@ class App extends HTMLElement {
|
||||||
await this._connect();
|
await this._connect();
|
||||||
this.dispatchEvent(new CustomEvent("load"));
|
this.dispatchEvent(new CustomEvent("load"));
|
||||||
|
|
||||||
this.mediaSessionInit = false;
|
|
||||||
this._initMediaHandler();
|
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);
|
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)
|
// Init event session (play audio) on click (because restrictions by web browsers)
|
||||||
|
let mediaSessionInit = false;
|
||||||
window.addEventListener('click', () => {
|
window.addEventListener('click', () => {
|
||||||
if (!this.mediaSessionInit) {
|
if (mediaSessionInit) return;
|
||||||
|
mediaSessionInit = true;
|
||||||
audio.play();
|
audio.play();
|
||||||
this.mediaSessionInit = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// mediaSession define metadata
|
// mediaSession define metadata
|
||||||
|
|
Loading…
Reference in a new issue