intarstudents.lv

Pile of Stuff

Reaction Test With HTML5 Audio

Yesterday friend asked if I could build reaction test with sound (he till now was using graphical) and I of course couldn’t crush his dreams (and because I really haven’t build anything interesting using audio tag).

So after while, falstart was made (online demo for those who aren’t interested in source code). It of course isn’t perfect (no fallback for unsupported browsers), but with Firefox 3.6.3 and Google Chrome 6.0.408.1 dev works good (Google Chrome better then Firefox, because of faster JavaScript engine).

And there was one interesting bug that I encountered during writing it, that Google Chrome was very slow with seeking audio file to beginning and made big gasp (well ~900 ms) before started playing it again (and those added it to user reaction time). Fast fix for it, was setting it by myself.

1
2
audioObject.pause();
audioObject.currentTime = 0;

That’s all, what was on my mind. Happy, your reaction testing!