The Media API
One of the complaints about using plug-ins to display audio and video is that they are dumb elements on the page; you can’t interact unless the plug-in specifically makes itself available. The HTML5 media elements, however, have the big advantage of an extensive API that allows you access to information about the media file and makes interacting simple. You access the API through a set of interfaces: Each media element has shared properties and methods in the HTMLMediaElement
interface; audio also has the unique HTMLAudioElement
interface; and video has HTMLVideoElement
.
The first two methods I’ll introduce have obvious functions: They are play()
and pause()
, and are simply applied to the media element. Given unique controls on ...
Get The Modern Web now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.