Click then start
This commit is contained in:
parent
1065b3385b
commit
e776f86f8a
17
main.js
17
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)
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue