In this article, we will see how we can change the playback speed of videos embedded in an HTML document using an HTML5 video tag.
We can set the new playing speed using playbackRate attribute. It has the following syntax.
Syntax:
let video = document.querySelector('video')
video.playbackRate = newPlaybackRate
We can also set the default playing speed using defaultPlaybackRate attribute. It has the following syntax.
Syntax:
let video = document.querySelector('video')
video.defaultPlaybackRate = 4
video.load()
Example: This example shows changing of playback speed using Javascript.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>change video playing speed using JavaScript</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
<video width="890" height="500" controls loop>
<source src="sample.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<p>
<button onclick="increase()">Increase Speed</button>
<button onclick="decrease()">Decrease Speed</button>
</p>
</body>
</html>
|
CSS
<style>body {
text-align: center;
margin-top: 2%;
}
h1 {
color: green;
}
p {
margin-top: 2%;
}
button {
margin-right: 20px;
}
</style>
|
Javascript
<script>
let video = document.querySelector('video');
video.defaultPlaybackRate = 0.5
video.load();
function increase() {
video.playbackRate += 1;
}
function decrease() {
if (video.playbackRate > 1)
video.playbackRate -= 1;
}
</script>
|
Output: Click here to check the live output

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!