HTML Audio & Video
HTML DOM Audio defaultPlaybackRate Property
The defaultPlaybackRate property sets or returns the default playback speed of a media element. This is the speed the media reverts to at the next playback, as opposed to playbackRate, which is the speed in effect right now.
Definition and Usage
A value of 1.0 is normal speed, 0.5 is half speed and 2.0 is double speed. defaultPlaybackRate stores the intended default; when playback is reset or restarted with load(), the current playbackRate is set back to this default value.
It is a number. Negative values are allowed by the spec to indicate reverse playback, though support for reverse playback is inconsistent across browsers.
Syntax
// Get the value
let rate = mediaElement.defaultPlaybackRate;
// Set the value
mediaElement.defaultPlaybackRate = 1.5;| Property | Meaning |
|---|---|
| playbackRate | The current, live speed applied to playback right now |
| defaultPlaybackRate | The default speed the element resets to on load() |
Example
This runnable page sets a default of 1.5x, calls load() to apply it, and reports both speed properties. It also lets you change the live playbackRate to see that defaultPlaybackRate stays put.
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>defaultPlaybackRate Demo</title></head>
<body>
<h2>Default speed vs live speed</h2>
<video id="myVideo" width="320" controls>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
</video>
<p>
<button onclick="live2x()">Live 2x</button>
<button onclick="report()">Show both</button>
</p>
<pre id="output"></pre>
<script>
const video = document.getElementById("myVideo");
// Media should default to 1.5x speed
video.defaultPlaybackRate = 1.5;
video.load(); // apply the default at (re)load
function live2x() { video.playbackRate = 2.0; } // current session only
function report() {
document.getElementById("output").textContent =
"playbackRate = " + video.playbackRate + "\n" +
"defaultPlaybackRate = " + video.defaultPlaybackRate;
}
</script>
</body>
</html>Use playbackRate to change speed immediately during playback. Use defaultPlaybackRate to set the speed the element resets to, which the browser also applies through the ratechange event flow.
Key Takeaways
- defaultPlaybackRate is the default speed applied on load()/reset.
- 1.0 is normal, 0.5 is half speed, 2.0 is double speed.
- playbackRate is the live speed; changing it does not touch defaultPlaybackRate.
- Set defaultPlaybackRate before load() to start at that speed.
- Negative values mean reverse playback, but browser support is inconsistent.
