From the course: Learning Web Audio and Video

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Listen for Media events

Listen for Media events

From the course: Learning Web Audio and Video

Start my 1-month free trial

Listen for Media events

- [Instructor] Through the HTML5 media API, we can listen for certain events and respond to those events as a function of our custom playback controls. This allows us to monitor and respond to user actions and playback events. Within our script tag, we're going to add a couple more empty lines here, right after our variable definitions. And here we can add some event listeners to the play button, pause button, rail, and our actual media element. First of all, we're do so for play, which once again refers to our play button. We'll add an event listener of type click. So this'll fire off whenever the user performs some sort of a click action upon the button. When that happens, it's going to invoke a specific function. We're going to name this function playMedia because that's what it's going to do is play the media for us. Notice in my function definition here that I've actually used an uppercase M. This is going to be very important because we need this name to match exactly with our…

Contents