Skip to content

Commit

Permalink
Añadir preload a sonidos
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-visma committed Oct 17, 2023
1 parent 7d1eb8a commit dae9517
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions math.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var Homework = /** @class */ (function () {
this.puntosNumero = document.getElementById('puntos-numero');
this.actualizarPuntos();
this.actualizarVidas();
this.preloadMP3();
// TODO añadir record personal usando storage
// TODO añadir juego igual / distinto
addEventListener('keypress', function (e) {
Expand Down Expand Up @@ -128,6 +129,15 @@ var Homework = /** @class */ (function () {
var audio = new Audio("sound/".concat(evento, "/0").concat(random, ".mp3"));
audio.play();
};
Homework.prototype.preloadMP3 = function () {
var audioFiles = [];
for (var i = 0; i <= 6; i++) {
var fileName = i < 10 ? "0" + i + ".mp3" : i + ".mp3";
var audio = new Audio("sound/acierto/" + fileName);
audio.preload = "auto";
audioFiles.push(audio);
}
};
return Homework;
}());
;
Expand Down
12 changes: 12 additions & 0 deletions math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Homework {
constructor() {
this.actualizarPuntos();
this.actualizarVidas();
this.preloadMP3();

// TODO añadir record personal usando storage
// TODO añadir juego igual / distinto
Expand Down Expand Up @@ -168,6 +169,17 @@ class Homework {
let audio = new Audio(`sound/${evento}/0${random}.mp3`);
audio.play();
}

preloadMP3() {
let audioFiles: HTMLAudioElement[] = [];

for (let i = 0; i <= 6; i++) {
let fileName: string = i < 10 ? "0" + i + ".mp3" : i + ".mp3";
let audio: HTMLAudioElement = new Audio("sound/acierto/" + fileName);
audio.preload = "auto";
audioFiles.push(audio);
}
}
};

const homeWork = new Homework();

0 comments on commit dae9517

Please sign in to comment.