HTML Audio/Video DOM ratechange Event
Example
//Accessing the element
var vid = document.getElementById("myVideo");
//Setting the current playback speed of the video to 0.5
function setPlaySpeed() {
vid.playbackRate = 0.5;
}
//Assign an onratechange event to the video element, and execute a function if the playing speed of the video is changed
vid.onratechange = function() {myFunction()};
//Creating a function
function myFunction() {
alert("The playing speed of the video was changed");
}
Meaning
The ratechange event run when the playing speed of the audio/video is changed.
Standard Syntax
HTML:
<element onratechange="myScript">
JavaScript:
object.onratechange=function(){myScript};
JavaScript, using the addEventListener() method::
object.addEventListener("ratechange", myScript);
Advertisement