Javascript DOM HTML Video playbackRate Property set to play faster

Introduction

Set a video to play fast:

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<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>

<button onclick="getPlaySpeed()" type="button">Get playback speed</button>
<button onclick="setPlaySpeed()" type="button">Set video to be play fast</button>

<script>
var x = document.getElementById("myVideo");
function getPlaySpeed() {//from  w w  w. j ava 2 s. co  m
  document.getElementById("demo").innerHTML = x.playbackRate;
}

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

</body>
</html>



PreviousNext

Related