Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Video ended Property
The HTML DOM Video ended property returns a boolean (true/false) corresponding to whether the video has reached its end or not.
Syntax
Following is the syntax −
Returning boolean value
mediaObject.ended
Let us see an example of HTML DOM Video ended property −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video ended</title>
<style>
* {
padding: 2px;
margin:5px;
}
form {
width:70%;
margin: 0 auto;
text-align: center;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Video-ended</legend>
<video id="demo" width="320" controls><source src="http://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="How many seconds before the video ends?">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var demo = document.getElementById("demo");
function getTrackDetails() {
if(demo.ended === false)
divDisplay.textContent = 'Video ends in: '+(demo.duration - demo.currentTime)+' seconds';
}
</script>
</body>
</html>
Output
Before clicking ‘How many seconds before the video ends?’ button −

After clicking ‘How many seconds before the video ends?’ button −

Advertisements