English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Reference

HTML Audio/Video DOM ended attribute

Check if the media element has ended playing using the ended attribute

 HTML Audio/Video DOM Reference Manual

Online Example

Check if the video playback has ended:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Audio/Video ended attribute usage-Basic Tutorial(oldtoolbag.com)</title>
</head>
<body>
<button onclick="hasVidEnded()" type="button">Check if the video playback has ended</button>
<br> 
<video id="video1" controls="controls">
  <source src="movie.mp4" type="video"/mp4">
  <source src="movie.ogg" type="video"/ogg">
  Your browser does not support HTML5 video tag.
</video>
<script>
myVid=document.getElementById("video1");
function hasVidEnded()
{ 
  alert(myVid.ended);
} 
</script> 
</body>
</html>
Test and see ‹/›

Definition and Usage

end property returns the audio/whether the video playback has ended.
when the playback position is at the audio/at the end of the video, the audio/The video has ended.
Note: This property is read-only.

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the ended property.

Note:Internet Explorer 8 and earlier versions do not support this property.

Syntax

audio|video.ended

Technical Details

Return value:Boolean value, true|false. It returns true if the playback has ended, otherwise false.
 HTML Audio/Video DOM Reference Manual