Let’s explore media events supported by HTML.
HTML Media Events
This section provides a detailed overview of the media events supported by the HTML.
onabort
This event appears when the loading of the media(audio/video) is aborted. This event supports <audio> and <video> tags.
Syntax
oncanplay
The oncanplay occurs when the specific media is about to play/run. For instance, if the video file is buffering(not completely buffered) enough to run, then this media event will be triggered for that element. The HTML tags supported by these media events are, <audio> and <video>.
Syntax
oncanplaythrough
This event happens when the specific media file is buffered completely. The oncanplaythrough event occurs after the oncanplay event.
Syntax
onemptied
As the name of the attribute shows, this event happens when the specific element contains an empty media element.
Syntax
onended
The event happens when some audio or video has ended. This event supports <audio> and <video> tags.
Syntax
ondurationchange
This event triggers when the duration of the specific audio/video file has been changed.
Syntax
onerror
This event happens when the loading of any external file is failed. The HTML elements supported by this event are, <img>, <input type=”img”>, <object>, <link>, and <script>.
Syntax
onloadeddata
This event happens when the media of the next frame is not enough to continue the uninterrupted play. The onloadeddata event supports <audio>, and <video>.
Syntax
onloadedmetadata
This event happens when the metadata of a specific media is loaded. The metadata refers to the duration and dimensions of that media element.
Syntax
onloadstart
This event happens whenever a specific media file is being loaded.
Syntax
onpause
This event occurs when the specific media is paused by any source (maybe a user or any program). The <audio> and <video> are the tags supported by this event.
Syntax
onplay
This event occurs when the media file is ready to start.
Syntax
onplaying
This event happens when the media has been started (by a user or a program).
Syntax
onprogress
This event happens when the browser is loading the media/audio file.
Syntax
onratechange
This event is triggered when the video is being played at a slower or faster rate than the original.
Syntax
onseeking
This event occurs when the user navigates to a new position in an audio/video file.
Syntax
onseeked
This event is triggered when the user has finished the seeking process.
Syntax
onstalled
The onstalled event happens when the browser is trying to fetch the media file but the file is not available.
Syntax
onsuspend
This event triggers when the media is available to fetch but either the browser does not want to load or the loading is paused due to some reason.
ontimeupdate
The ontimeupdate event occurs when the playing position (playing the media file by navigating to a different time) of the media file is changed.
Syntax
onvolumechange
As the name shows, the event is triggered when the volume of the media file has been changed.
Syntax
onwaiting
The onwaiting event is triggered when the video is interrupted to buffer the next frame.
Syntax
From the above-provided information, you would have learned the application of various media events.
Conclusion
The HTML events occur whenever any kind of manipulation happens to the media elements on the page. The HTML 5 is quite rich regarding the media events, as the number of media events has been increased from the previous HTML version. This article enlists the HTML media events, their purpose, and the syntax supported by all. The HTML media events can be used to keep a focus on the change that occurs due to the media.
from https://ift.tt/gnq6afB
0 Comments