English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Check if the media element has ended playing using the ended attribute
HTML Audio/Video DOM Reference Manual
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 ‹/›
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.
IEFirefoxOperaChromeSafari
All major browsers support the ended property.
Note:Internet Explorer 8 and earlier versions do not support this property.
audio|video.ended
Return value: | Boolean value, true|false. It returns true if the playback has ended, otherwise false. |
---|