mirror of
https://framagit.org/JonathanMM/sutom.git
synced 2024-06-10 09:52:13 +02:00
Raccourcissement des sons
This commit is contained in:
parent
1b1da601f8
commit
7fe0b2dffa
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue