Add Play and Pause Events to the Audio Player

InstructorLindsey Kopacz

Share this video with your friends

Send Tweet

In this lesson, we will create event listeners for the play and pause events on an audio player element and use these listeners to update the value of a variable called isPlaying that tracks the current state of the player (e.g., whether it is currently playing or paused). The event listeners, named onPlay and onPause, will be triggered when the user presses the play or pause button on the audio player element itself, not on a custom play button that may have been created.