Video defaultPlaybackRate Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video

Description

The defaultPlaybackRate property sets or gets the default playback speed of the video.

Set the defaultPlaybackRate property with the following Values

Value Description
number Indicates the default playback speed of the video.

Example values:

  • 1.0 is normal speed
  • 0.5 is half speed (slower)
  • 2.0 is double speed (faster)
  • -1.0 is backwards, normal speed
  • -0.5 is backwards, half speed

The value 0.0 is invalid and throws a NOT_SUPPORTED_ERR exception

Return Value

A Number, representing the default playback speed

Default Value is 1.0

The following code shows how to Set the video to slow motion by default:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="320" height="240" controls>
  <source src="your.mp4" type="video/mp4">
  <source src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video><br>

<button onclick="getPlaySpeed()" type="button">What is 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 w  w w  . j a  va 2s .  co m*/
    console.log(x.defaultPlaybackRate);
}

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

</body>
</html>

Related Tutorials