Execute a JavaScript when the playing speed of the video is changed: - Javascript DOM Event

Javascript examples for DOM Event:onratechange

Description

Execute a JavaScript when the playing speed of the video is changed:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="320" height="240" autoplay controls onratechange="myFunction()">
  <source src="your.mp4" type="video/mp4">
  <source src="your.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>

<script>
var x = document.getElementById("myVideo");

function setPlaySpeed() {//from ww  w .  j a  v  a 2s  . c o  m
    x.playbackRate = 0.3;
}

function myFunction() {
    console.log("The playing speed of the video was changed");
}
</script>

</body>
</html>

Related Tutorials