Horje

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




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