PLAYING SOUNDS

Example of playing sounds using the HTML5 audio tag.

These solutions exploits both the audio and embed tags: if the first is not recognized by the browser, the second will try to use the native plugin (e.g. QuickPlay or Flash). The last example (the Play button) shows how to play a sound using the JavaScript API.

To browse the code click on the Show code, Show markup labels below.




Autoplay (preloaded): invisible since we don't specify the control property

Controls:

Looping:



Show code


Show markup




References:

W3C HTML Audio
W3C HTML5 tag
Playing and inspection
API and manipulation