It may seem pointless to make the controls attribute optional in the <audio> and <video> tags. When omitted, no playback buttons will appear in the web browser. This is actually intentional, as you can still control the playback of either element using some simple JavaScript methods and event listeners.

This moves control over the playback experience from the user to the website itself. Your goal as a web developer should be to only trigger playback when it is appropriate, such as during an HTML5 Canvas game or when chaining playback of multiple video files together.

Before you begin, you must locate the audio or video element in the JavaScript DOM. The easiest way to do this is to assign the element ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.