In this example, we assign an "onratechange" event to a video element.
The playbackRate property is used to change the playing speed of the video.
<!DOCTYPE html> <html> <body> <video id="myVideo" width="100" height="100" autoplay //from w w w .j ava 2 s .com controls onratechange="myFunction()"> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> Your browser does not support the video tag. </video><br> <p id="demo"></p> <button onclick="setPlaySpeed()" type="button"> Set video to be play in slow motion</button> <script> // Get the video element with id="myVideo" var x = document.getElementById("myVideo"); // Set the current playback speed of the video to 0.3 (slow motion) function setPlaySpeed() { x.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>
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <audio> and <video> |