From 1b1da601f84d08e0dd57f8fe2da44fa5de2c1721 Mon Sep 17 00:00:00 2001 From: JonathanMM Date: Mon, 17 Jan 2022 22:11:23 +0100 Subject: [PATCH] =?UTF-8?q?Probl=C3=A8me=20avec=20les=20sons=20sur=20Vival?= =?UTF-8?q?di?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ts/audioPanel.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ts/audioPanel.ts b/ts/audioPanel.ts index aba5264..30ad5ab 100644 --- a/ts/audioPanel.ts +++ b/ts/audioPanel.ts @@ -66,11 +66,18 @@ export default class AudioPanel { } baliseAudio.currentTime = 0; if (callback) baliseAudio.addEventListener("ended", callback, { once: true }); - baliseAudio.play().catch( - (() => { - this._hasAudio = false; - if (callback) setTimeout(callback, 250); - }).bind(this) - ); + try { + baliseAudio.play().catch( + (() => { + this._hasAudio = false; + if (callback) setTimeout(callback, 250); + }).bind(this) + ); + } catch ( + ex // Parfois, le play ne retourne pas de promiseā€¦ + ) { + this._hasAudio = false; + if (callback) setTimeout(callback, 250); + } } }