delay loading sounds

prod-hotfix
Thibault Duplessis 2021-01-29 10:23:19 +01:00
parent 792e45c2b5
commit e821b57ba5
1 changed files with 4 additions and 4 deletions

View File

@ -238,15 +238,15 @@ export default class StormCtrl {
private uciToLastMove = (uci: string): [Key, Key] => [uci.substr(0, 2) as Key, uci.substr(2, 2) as Key];
private loadSound = (file: string, volume?: number) => {
lichess.sound.loadOggOrMp3(file, `${lichess.sound.baseUrl}/${file}`);
private loadSound = (file: string, volume?: number, delay?: number) => {
setTimeout(() => lichess.sound.loadOggOrMp3(file, `${lichess.sound.baseUrl}/${file}`), delay || 1000);
return () => lichess.sound.play(file, volume);
};
private sound = {
move: (take: boolean) => lichess.sound.play(take ? 'capture' : 'move'),
bonus: this.loadSound('other/ping', 0.8),
end: this.loadSound('other/gewonnen', 0.6)
bonus: this.loadSound('other/ping', 0.8, 1000),
end: this.loadSound('other/gewonnen', 0.6, 5000)
};
private checkDupTab = () => {