How to change the playing speed of videos in HTML5 and JavaScript?

Spread the love

Sometimes, we want to change the playing speed of videos in HTML5 and JavaScript.

In this article, we’ll look at how to change the playing speed of videos in HTML5 and JavaScript.

How to change the playing speed of videos in HTML5 and JavaScript?

To change the playing speed of videos in HTML5 and JavaScript, we set the playbackRate property.

For instance, we write

document.querySelector("video").defaultPlaybackRate = 2.0;
document.querySelector("video").play();
document.querySelector("video").playbackRate = 3.0;

to select the video element with querySelector.

Then we set its playbackRate property to 3 to make it 3 times faster than the original speed.

We can also set the default speed by setting the defaultPlaybackRate property.

Conclusion

To change the playing speed of videos in HTML5 and JavaScript, we set the playbackRate property.

Leave a Reply

Your email address will not be published. Required fields are marked *