Home > Web Front-end > H5 Tutorial > body text

HTML5 returns the attribute of whether the audio/video has ended

黄舟
Release: 2017-11-08 14:00:45
Original
3399 people have browsed it

Example

Check whether videoplayback has ended:

myVid=document.getElementById("video1");
alert(myVid.ended);
Copy after login

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
Copy after login

Return value

TypeDescription
Boolean valuetrue|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>
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!