Customizing controls for media elements

Media elements, currently video and audio, can be controlled using JavaScript since the elements theme self contain useful methods and attributes. In this recipe, we will go through some of the most basic functionality and methods that can be applied on elements that have the HTMLMediaElement interface.


Specification on the HTML5 media element can be found at

Getting ready

In this recipe we will also need a video file, so we can use the same one from the previous recipe.

How to do it...

We start by creating a JavaScript controller that will have very rudimentary functionality of a media player.

  1. Our controller methods will accept a selector ...

Get HTML5 Data and Services Cookbook now with O’Reilly online learning.

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