diff --git a/main.js b/main.js index 0e14e41..2504364 100644 --- a/main.js +++ b/main.js @@ -18,6 +18,7 @@ let app = { initialColor: Math.random() * 360, rid: 0, beepTimer: undefined, + sound: undefined, }; }, watch: { @@ -103,26 +104,8 @@ let app = { Math.floor(Math.abs(delta) / 60) ).padStart(2, "0")}:${String(Math.abs(delta) % 60).padStart(2, "0")}`; }, - beep(remaining = 3) { - if (remaining < 0) { - return; - } - const context = new AudioContext(); - const oscillator = context.createOscillator(); - const volume = context.createGain(); - volume.gain.value = 0.1; - oscillator.type = "sine"; - oscillator.frequency.value = 800; - oscillator.connect(context.destination); - oscillator.connect(volume); - oscillator.start(); - const self = this; - setTimeout(function () { - oscillator.stop(); - setTimeout(function () { - self.beep(remaining - 1); - }, 1000); - }, 150); + beep() { + this.sound.play(); }, timeText(minutes) { if (minutes >= 60) { @@ -243,6 +226,7 @@ let app = { }, mounted: function () { console.log("app mounted"); + this.sound = new Audio("./sound.wav"); this.rawData = atob(this.getCookie("rawData", btoa(this.rawData))); this.data = this.getData(); setTimeout(this.showApp); diff --git a/sound.wav b/sound.wav new file mode 100644 index 0000000..fd43c82 Binary files /dev/null and b/sound.wav differ