I wanted to be a memelord and time the beat drop of a specific song to land exactly on midnight. Only problem is human error (since its BPM is not a multiple of 60), so I figured I’d write a script that does it for me.
I found some code online that has a JavaScript clock down to the millisecond, in a function updateClock that has this line of code, where now is a new Date():
var milli = now.getMilliseconds(),
sec = now.getSeconds(),
min = now.getMinutes(),
hou = now.getHours(),
mo = now.getMonth(),
dy = now.getDate(),
yr = now.getFullYear();
I was thinking of writing an if statement where if min, sec and milli were of or greater than a certain value, it would play an mp3 file.
My concerns are that since it’s constantly updating, I was worried that if I use ==, it would skip so fast to where a 60Hz refresh rate wouldn’t catch the value, and if I use >=, it would repeatedly start playing the mp3 file and spamming it for every instance the condition is true.
Not sure how to remedy this. I’m a novice.
Aucun commentaire:
Enregistrer un commentaire