Video loop Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video

Description

The loop property sets or gets whether a video should start playing over again when it is finished.

This property reflects the <video> loop attribute.

Set the loop property with the following Values

Value Description
true|false Sets whether the video should start playing over again, every time it is finished

Return Value

A Boolean, returns true if the video starts playing over again, every time it is finished. Otherwise it returns false

Default Value is false

The following code shows how to Set the video to loop:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="320" height="240" controls loop>
  <source src="your.mp4" type="video/mp4">
  <source src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>/*from w w w.  ja  v a 2s.  c  om*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myVideo").loop = true;

}
</script>

</body>
</html>

Related Tutorials