I would like to play music (with HTML5 audio) and show some graphical elements at particular times (should be synced with audio timing).
Would it be OK to use JavaScript's window.setTimeout
function to do it?
setTimeout(function() {
requestAnimationFrame(function() {
// display something
});
}, 1400);
setTimeout(function() {
requestAnimationFrame(function() {
// display something else
});
}, 2300);
Or, are there any better ways to do this?