English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The autoplay property of HTMLMediaElement is equivalent to the autoplay attribute in HTML, indicating whether the video should play automatically when the player has downloaded enough media files to play. Note: Some versions of Chrome only support autostart, not autoplay
HTML Audio/Video DOM Reference Manual
Enable autoplay and reload the video:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Using the video audioTracks property-Basic Tutorial(oldtoolbag.com)</title>/<title> </<head> <body> <button onclick="enableAutoplay()" type="button">Enable autoplay</button> <button onclick="disableAutoplay()" type="button">Disable autoplay</button> <button onclick="checkAutoplay()" type="button">Check autoplay status</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 enableAutoplay() { myVid.autoplay=true; myVid.load(); } function disableAutoplay() { myVid.autoplay=false; myVid.load(); } function checkAutoplay()} { alert(myVid.autoplay); } </script> </body> </html>Test and see ‹/›
autoplay attribute sets or returns whether the audio is loaded/Start playing the video immediately after the video.
IEFirefoxOperaChromeSafari
All major browsers support the autoplay attribute.
Note:Internet Explorer 8 And earlier versions do not support this attribute.
Set autoplay attribute:
audio|video.autoplay=true|false
Return autoplay attribute:
audio|video.autoplay
Value | Description |
---|---|
true | Indicates the audio/The video should start playing immediately after loading. |
false | Default. Indicates the audio/The video should not start playing immediately after loading. |
Return value: | Boolean value, true|false |
---|---|
Default value: | false |