Advertisement
Home Open Editor ❯

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");
}

Try this code ❯

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

Technical Details

Type Description
Supported HTML tags: <audio> and <video>
Supported JavaScript objects: Audio, Video
Home Open Editor ❯
Advertisement