diff --git a/main.js b/main.js index b7de52a..26d8275 100644 --- a/main.js +++ b/main.js @@ -74,9 +74,17 @@ fetch("Contra.webm").then(e => e.arrayBuffer()).then(e => { source.connect(analyser); source.connect(audioCtx.destination); +let started = false; canvas.addEventListener("click",async ()=>{ await audioCtx.resume(); source.start(); + started = true; +},{once:true}) + +canvas.addEventListener("touchend",async ()=>{ + await audioCtx.resume(); + source.start(); + started = true; },{once:true}) analyser.fftSize = 2 ** 13; @@ -125,6 +133,15 @@ function RenderWave() ctx.lineTo(width, height / 2); ctx.stroke(); + if(!started) + { + ctx.font = ((width * .05)|0)+"px ubuntu"; + ctx.textBaseline = "middle"; + ctx.textAlign = "center"; + ctx.fillStyle = "black"; + ctx.fillText("Başlatmak için dokunun", width / 2, height / 2); + } + requestAnimationFrame(RenderWave) };