background preloader

HTML 5

Facebook Twitter

Mastering the HTML5 <audio> tag. Using <audio> to insert a sound file on your website Here is the most basic use of the <audio> tag: On this example it loads a mp3 file and play it. Notice the autoplay attribute which is used to play the sound automatically. That said, you shouldn’t play sounds automatically on a website: this is extremely boring for visitors. Play sound in loop Want to loop a sound? Display browser controls Instead of playing sounds automatically, which is definitely a bad practice, you should let the browser display some controls such as volume, and a play/pause button. Multiple file formats <audio> is supported by most modern browsers, but the problem is that different browsers do not support the same file format. Specify MIME types When using different file formats, it is a good practice to specify the MIME type of each file in order to help browser to localize the file they support.

Fallback for old browsers Buffer files When playing large files, it is indeed a good idea to buffer files. 23 Essential HTML 5 Resources. Www.nihilogic.dk/labs/canvas_sheet/HTML5_Canvas_Cheat_Sheet.pdf. Downloads/free/html5-quick-learning-quide.pdf. Www.ibm.com/developerworks/web/tutorials/wa-html5/wa-html5-pdf.pdf. Dive Into HTML5.