Horje
HTML onratechange Event Attribute
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).

Example of HTML onratechange Event Attribute

It will change the playing speed of a video and alert that the speed was changed.
index.html
Example: HTML
 <script>
function myFunction() {
  alert("onratechange attribute fired - The playing speed of the video was changed");
}
</script>

<video onratechange="myFunction()"> 

Output should be:

Example of HTML onratechange Event Attribute

Definition and Usage of 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).

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.

Browser Support of HTML onratechange Event Attribute

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

Browser Support of HTML onratechange Event Attribute

Syntax of HTML onratechange Event Attribute

<element onratechange="script">

Attribute Values of HTML onratechange Event Attribute

Value Description
script The script to be run when the playing speed changes

Technical Details of HTML onratechange Event Attribute

Supported HTML tags: <audio> and <video>

Change the playing speed of a video and alert that the speed was changed

It will Cclick the button to trigger the "ratechange" event.

index.html
Example: HTML
<!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>

Output should be:

Change the playing speed of a video and alert that the speed was changed




html event attributes

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Media Events Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference