html tutorial - onplay Attribute in HTML - html5 - html code - html form
Learn html - html tutorial - Onplay attribute in html - html examples - html programs
- The onplay attribute used to trigger an event when the audio/video has been started or is no longer paused.
- The onplay attribute is an Event Attributes.
Syntax for onplay attribute in HTML:
onplay Attribute Value:
|script||The script to be run on onplay|
Sample Coding for onplay Attribute in HTML:
Code Explanation for onplay Attribute in HTML:
- <video> tag is used to display the video with width and height as “300”.
- <source> tag is used to specify the source of the video resources.
- src is an attribute, which describes the location of the “Hibiscus.mp4” video file.
- alert() method shows an alert box with a “The video is playing” message.
Output for onplay Attribute in HTML:
- The video file has been displayed.
- When user click the play button to play the video.
- The alert box The Video is playing is displayed here.
- After clicking the ok button, the video has been played.
Browser Support for onplay Attribute in HTML:
Tips and Notes
- The onpause attribute is used to specify a script though the audio/video has been paused.