The onratechange attribute handles the media ratechange event. It fires when the playback rate (speed) of a <video> or <audio> element changes.
Change speed with media.playbackRate (e.g. 1.5 for 1.5×). Related media handlers: onplay, onpause, onvolumechange. Prefer addEventListener("ratechange", …).
Baseline · Widely available.
Stable across modern browsers since about July 2015. Not deprecated. Not cancelable; does not bubble.
Inline handlers discouraged.
MDN: prefer addEventListener over inline on* attributes. Study onratechange to recognize it in markup.
Syntax
HTML Syntax
syntax.html
<video onratechange="script">
script runs when playbackRate changes. Same idea on <audio>. Preferred: element.addEventListener("ratechange", handler).
aria-live announces the new speed to assistive tech.
Edge Cases & Pitfalls
Most issues come from listening in the wrong place or expecting pitch control.
target
Listen on the media element
ratechange does not bubble. Put the handler on <video> / <audio>, not a parent wrapper.
value
Use playbackRate
The event itself has no rate field. Read media.playbackRate inside the handler.
limits
Browser clamps extreme rates
Very high or negative rates may be clamped or ignored. Stick to common values like 0.5–2 for demos.
pitch
Pitch may change with speed
Default playback often raises pitch when speeding up. Preserving pitch needs extra APIs beyond this attribute.
style
Prefer listeners
Inline on* attributes mix concerns. Use addEventListener in production code.
Compatibility
Browser Support
onratechange is a media event handler for playbackRate changes on video/audio. Prefer addEventListener in apps.
✓ Baseline · Widely available
onratechange
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the media ratechange event.
97%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet Explorer9+
Supported*
ratechangeWidely supported
Bottom line: *Safe on modern browsers. Read playbackRate in the handler; listen on the media element.
Remember
Key Takeaways
Role: run script when media playback speed changes.
Set speed with:media.playbackRate.
Target:<video> / <audio> (no bubbling).
Prefer:addEventListener("ratechange", …).
One line:onratechange fires when playbackRate changes — listen on the media element and update your speed UI from that property.
Frequently Asked Questions
It is an event handler for the ratechange event on media elements. That event fires when the playback rate (speed) of a video or audio element changes.
Set media.playbackRate. For example, video.playbackRate = 1.5 plays at 1.5× speed. A rate of 1 is normal speed; 0.5 is half speed; 2 is double speed.
On HTMLMediaElement targets such as <video> and <audio>. Prefer element.addEventListener("ratechange", handler) in modern code.
No. It is not cancelable and does not bubble. Listen on the media element itself.
Prefer addEventListener("ratechange", handler). MDN discourages inline HTML event handler attributes.
Common uses: show the current speed in the UI, sync a custom speed control, or log when users change playback speed.