|
|
HTML onratechange Event Attribute The ratechange event occurs when the playing speed of the audio/video is changed (like when a user switches to a slow motion or fast forward mode).
|
<script>
function myFunction() {
alert("onratechange attribute fired - The playing speed of the video was changed");
}
</script>
<video onratechange="myFunction()">
The ratechange event occurs when the playing speed of the audio/video is changed (like when a user switches to a slow motion or fast forward mode).
This event is invoked by the playbackRate property of the Audio/Video Object, which sets or returns the current playback speed of an audio/video.
The numbers in the table specify the first browser version that fully supports the event.
<element onratechange="script">
| Value | Description |
|---|---|
| script | The script to be run when the playing speed changes |
| Supported HTML tags: | <audio> and <video> |
|---|
It will Cclick the button to trigger the "ratechange" event.
<!DOCTYPE html>
<html>
<body>
<script>
function setPlaySpeed() {
document.getElementById("myvideo").playbackRate = 0.3;
}
function myFunction() {
alert("onratechange attribute fired - The playing speed of the video was changed");
}
</script>
<p>Click the button to trigger the "ratechange" event.</p>
<video id="myvideo" autoplay controls onratechange="myFunction()">
<source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/mp4">
<source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<br>
<button onclick="setPlaySpeed()" type="button">Set video to be play in slow motion</button>
<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
</body>
</html>
| html event attributes |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Media Events Attribute |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference