Javascript DOM HTML Video ended Property get

Introduction

Find out if the video has ended:

var x = document.getElementById("myVideo").ended;

Click the button to find out if the video has ended.

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>//from w  ww  . j  a  v  a  2s.c om
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  var x = document.getElementById("myVideo").ended;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The ended property returns whether the playback of the video has ended.

This property is read-only.

The ended property returns true if the playback has ended, otherwise it returns false.




PreviousNext

Related