HTML Video playbackRate Property: Video Playback Rate

June 19, 2025

HTML Video playbackRate Property: Controlling Video Playback Speed

The HTML Video playbackRate property allows you to get or set the current playback speed of a video. This property enables users to speed up or slow down video playback, providing a more flexible viewing experience.

Understanding the playbackRate Property

The playbackRate property controls the speed at which the video is playing. A value of 1.0 represents normal speed. Values greater than 1.0 increase the speed, while values less than 1.0 decrease the speed. Negative values are not allowed and will result in an error.

Syntax

Getting the Playback Rate

let currentRate = video.playbackRate;

Setting the Playback Rate

video.playbackRate = speed; // speed is a number

Property Values

Value Description
Any positive number Specifies the playback rate. 1.0 is normal speed, 0.5 is half speed, 2.0 is double speed, etc.

Examples

Basic Example: Setting Playback Rate

This example demonstrates how to set the playback rate of a video using JavaScript.

<video id="myVideo1" width="320" height="176" controls>
  <source
    src="https://www.w3schools.com/html/movie.mp4"
    type="video/mp4"
  />
  Your browser does not support the video tag.
</video>

<button onclick="setPlaybackRate1()">Set Playback Rate to 2.0</button>

<script>
  function setPlaybackRate1() {
    const video1 = document.getElementById("myVideo1");
    video1.playbackRate = 2.0;
  }
</script>

In this example, clicking the button sets the playback rate of the video to 2.0, effectively doubling the playback speed.

Example: Creating Playback Speed Controls

This example demonstrates how to create buttons to control the playback speed of a video.

<video id="myVideo2" width="320" height="176" controls>
  <source
    src="https://www.w3schools.com/html/movie.mp4"
    type="video/mp4"
  />
  Your browser does not support the video tag.
</video>

<button onclick="changePlaybackRate2(0.5)">Slow Down</button>
<button onclick="changePlaybackRate2(1.0)">Normal</button>
<button onclick="changePlaybackRate2(2.0)">Speed Up</button>

<script>
  function changePlaybackRate2(rate) {
    const video2 = document.getElementById("myVideo2");
    video2.playbackRate = rate;
  }
</script>

This example provides three buttons: “Slow Down,” “Normal,” and “Speed Up.” Clicking each button adjusts the playback rate of the video accordingly.

Example: Displaying the Current Playback Rate

This example shows how to display the current playback rate of the video.

<video id="myVideo3" width="320" height="176" controls ontimeupdate="displayRate3()">
  <source
    src="https://www.w3schools.com/html/movie.mp4"
    type="video/mp4"
  />
  Your browser does not support the video tag.
</video>

<p>Current Playback Rate: <span id="playbackRateDisplay3">1.0</span></p>

<button onclick="speedUp3()">Speed Up</button>

<script>
  const video3 = document.getElementById("myVideo3");
  const playbackRateDisplay3 = document.getElementById("playbackRateDisplay3");

  function displayRate3() {
    playbackRateDisplay3.textContent = video3.playbackRate.toFixed(1);
  }

  function speedUp3() {
    video3.playbackRate += 0.1;
    displayRate3();
  }
</script>

In this example, the current playback rate is displayed and updated whenever the video’s time updates. Clicking the “Speed Up” button increases the playback rate by 0.1.

Example: Limiting Playback Rate Range

This example shows how to limit the playback rate to a specific range to prevent extreme speeds.

<video id="myVideo4" width="320" height="176" controls>
  <source
    src="https://www.w3schools.com/html/movie.mp4"
    type="video/mp4"
  />
  Your browser does not support the video tag.
</video>

<button onclick="adjustRate4(0.25)">Slower</button>
<button onclick="adjustRate4(-0.25)">Faster</button>

<script>
  const video4 = document.getElementById("myVideo4");
  const minRate4 = 0.5;
  const maxRate4 = 2.0;

  function adjustRate4(change) {
    let newRate4 = video4.playbackRate + change;

    // Limit the playback rate range
    if (newRate4 < minRate4) {
      newRate4 = minRate4;
    } else if (newRate4 > maxRate4) {
      newRate4 = maxRate4;
    }

    video4.playbackRate = newRate4;
    console.log("Playback rate:", video4.playbackRate);
  }
</script>

Here, the adjustRate4 function limits the playback rate between 0.5 and 2.0, ensuring that the video doesn’t play too slowly or too quickly.

Common Issues and Considerations

  1. Browser Compatibility: While most modern browsers support the playbackRate property, older browsers might not. Always test your implementation across different browsers.
  2. Audio Distortion: Extreme playback rates (very high or very low) can cause audio distortion. Consider implementing audio pitch correction to mitigate this issue.
  3. User Experience: Provide clear controls for adjusting the playback rate so users can easily customize their viewing experience.

Tips and Best Practices

  • Provide Clear Controls: Ensure users can easily adjust the playback rate with intuitive controls. 🎛️
  • Limit Extreme Values: Restrict the range of allowed playback rates to avoid audio and visual artifacts. 📉
  • Test on Multiple Browsers: Always test your implementation on different browsers to ensure compatibility. 🧪

Browser Support

The playbackRate property is widely supported across modern browsers:

  • Chrome
  • Edge
  • Firefox
  • Safari
  • Opera

Conclusion

The HTML Video playbackRate property is a valuable tool for enhancing the user experience by allowing viewers to control the playback speed of videos. By understanding how to use this property effectively, you can provide a more flexible and customizable viewing experience for your users.