``` More examples are included at the bottom of this page."> ``` More examples are included at the bottom of this page." />
Easy Tutorial
❮ Dom Obj Datetime Local Dom Obj All ❯

onplay Event

Event Object

Example

Execute JavaScript when a video starts playing:

<video onplay="myFunction()">

More examples are included at the bottom of this page.


Definition and Usage

The onplay event is triggered when a video/audio (audio/video) starts playing.

Tip: The onpause event is triggered when a video/audio (audio/video) is paused.


Browser Support

The numbers in the table specify the first browser version that supports the event.

Event Chrome IE Firefox Safari Opera
onplay Yes 9.0 Yes Yes Yes

Syntax

In HTML:

In JavaScript:

In JavaScript, using the addEventListener() method:

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Bubbles: No
Cancelable: No
--- ---
Event Type: Event
--- ---
Supported HTML Tags: <audio>, <video>
--- ---

More Examples

Example

Execute JavaScript when an audio starts playing:

<audio onplay="myFunction()">

❮ Dom Obj Datetime Local Dom Obj All ❯