Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html> 
<html> 
<body> 
<h1>HTML DOM Events</h1>
<h2>The onratechange Event</h2>
<p>Use the HTML DOM to assign an "onratechange" event to a video element.</p>
<p>Use the playbackRate property to change the speed of the video:</p>
<video id="myVideo" width="320" height="240" autoplay controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video><br>
<button onclick="setPlaySpeed()" type="button">Set video to be play in slow motion</button>
<p id="demo"></p>
<script>
// Get the video element:
const video = document.getElementById("myVideo");
// Assign an onratechange event to the video element
video.onratechange = function() {myFunction()};
// Set the playback speed to 0.3 (slow motion)
function setPlaySpeed() { 
  video.playbackRate = 0.3;
} 
// Alert some text when the playing speed of the video is changed
function myFunction() { 
  document.getElementById("demo").innerHTML = "The playing speed of the video was changed.";
}
</script> 
</body> 
</html>