Javascript DOM HTML Video defaultPlaybackRate Property set to play faster

Introduction

Set the video to play faster by default:

document.getElementById("myVideo").defaultPlaybackRate = 5;

View in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="100" height="100" controls>
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video><br>
<p id="demo"></p>
<button onclick="getPlaySpeed()" type="button">get the default playback speed?</button>
<button onclick="setPlaySpeed()" type="button">Set video to be play faster</button>

<script>
var x = document.getElementById("myVideo");
function getPlaySpeed() {//from  ww  w .  j  av a 2 s.  c o  m
  document.getElementById("demo").innerHTML =x.defaultPlaybackRate;
}

function setPlaySpeed() {
  x.defaultPlaybackRate = 5;
  x.load();
}
</script>

</body>
</html>



PreviousNext

Related