<video onratechange="myFunction()"> - Javascript DOM Event

Javascript examples for DOM Event:onratechange

Description

The onratechange 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).

Summary

Bubbles No
Cancelable No
Supported HTML tags: <audio> and <video>

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  www. j  av  a  2  s.com
    x.playbackRate = 0.3;
}
function myFunction() {
    console.log("The playing speed of the video was changed");
}
</script>

</body>
</html>

Related Tutorials