Zounds Javascript / Typescript Audio Library

Zounds is a javascript / typescript Audio Library that can add simple responsive sounds to your website or provide an audio engine for an entire javascript game.

Zounds works with all browsers that support the Web Audio API whist encapsulating that API's asynchronous nature.

The non-minified version has a full set of JSDoc comments.

What can it do?

So.... Gime a simple example!

For it to work you need to download and import the zounds script in your html head:

Give the button the following onclick attribute:

onclick="zounds.playURL('sounds/boing.mp3');"

..and that's it. Zounds will cache the sound on first use, any other use of the same URL through Zounds will use that cache.

Can I precache the sounds?

Add this script in the header:

Give the button the following attribute:

onclick="tiktok.play();"

What's more if the sound is still being loaded when this is clicked, it will play as soon as it can. Alternatively there is also a method to register a callback to get zounds to notify you when it's done, so you can hold something up till the sounds are ready.

Grab the .min.js file here.
Grab the .js file with JSDoc comments here.
See the Git project at Gitlab