Example
Check whether videoplayback has ended:
myVid=document.getElementById("video1"); alert(myVid.ended);
Definition and usage
ended attribute returnsaudio/ Whether the video has ended.
If the playback position is at the end of the audio/video, the audio/video has ended.
Browser support
All major browsers support the ended attribute.
Note: This attribute is not supported in Internet Explorer 8 or earlier browsers.
Syntax
audio|video.ended
Return value
Type | Description |
Boolean value | true|false. Returns true if playback has ended. Otherwise return false. |
Example
Check whether the video playback has ended:
<!DOCTYPE html> <html> <body> <p> <button onclick="hasVidEnded()" type="button">该视频播放是否已结束?</button> </p> <video id="video1" controls="controls"> <source src="/kf51/demo/mov_bbb.mp4" type="video/mp4"> <source src="/kf51/demo/mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 video 标签。 </video> <script> var myVid = document.getElementById("video1"); function hasVidEnded() { alert(myVid.ended); } </script> </body> </html>
The above is the detailed content of HTML5 returns the attribute of whether the audio/video has ended. For more information, please follow other related articles on the PHP Chinese website!