autoplay
HTML autoplay Attribute (HTML自动播放属性)
The HTML autoplay attribute is a boolean attribute and specifies that the audio or video will start playing automatically as soon as possible. (HTML自动播放属性是一个布尔属性,指定音频或视频将尽快自动开始播放。)
You can use this attribute on the following elements: <audio> and <video>.
Syntax
Syntax (语法)
<tag autoplay></tag>
Example of the HTML autoplay attribute used on the <audio> element:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<audio controls autoplay>
<source src="/build/audios/jingle_bells.ogg" type="audio/ogg">
<source src="/build/audios/audio.mp3" type="audio/mpeg">
</audio>
<p>Click the play button</p>
</body>
</html>
Example of the HTML autoplay attribute used on the <video> element:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<video width="320" height="240" controls autoplay>
<source src=”http://techslides.com/demos/sample-videos/small.ogv” type=video/ogg>
<source src="/build/videos/arcnet.io(7-sec).mp4" type=video/mp4>
</video>
<p>Some information about video</p>
</body>
</html>