Raccourcissement des sons

This commit is contained in:
JonathanMM 2022-01-17 22:18:59 +01:00
parent 1b1da601f8
commit 7fe0b2dffa
4 changed files with 5 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -9,6 +9,8 @@ export default class AudioPanel {
private readonly _audioLettreMalPlace: HTMLAudioElement; private readonly _audioLettreMalPlace: HTMLAudioElement;
private readonly _audioLettreNonTrouve: HTMLAudioElement; private readonly _audioLettreNonTrouve: HTMLAudioElement;
private readonly _longueurSon: number = 220;
private _hasAudio: boolean = false; private _hasAudio: boolean = false;
public constructor(configuration: Configuration) { public constructor(configuration: Configuration) {
@ -61,7 +63,7 @@ export default class AudioPanel {
private jouerSon(baliseAudio: HTMLAudioElement, callback?: () => void): void { private jouerSon(baliseAudio: HTMLAudioElement, callback?: () => void): void {
if (!this._hasAudio) { if (!this._hasAudio) {
if (callback) setTimeout(callback, 250); if (callback) setTimeout(callback, this._longueurSon);
return; return;
} }
baliseAudio.currentTime = 0; baliseAudio.currentTime = 0;
@ -70,14 +72,14 @@ export default class AudioPanel {
baliseAudio.play().catch( baliseAudio.play().catch(
(() => { (() => {
this._hasAudio = false; this._hasAudio = false;
if (callback) setTimeout(callback, 250); if (callback) setTimeout(callback, this._longueurSon);
}).bind(this) }).bind(this)
); );
} catch ( } catch (
ex // Parfois, le play ne retourne pas de promise… ex // Parfois, le play ne retourne pas de promise…
) { ) {
this._hasAudio = false; this._hasAudio = false;
if (callback) setTimeout(callback, 250); if (callback) setTimeout(callback, this._longueurSon);
} }
} }
} }