The autoplay
attribute on a media player specifies that the element immediately starts playing the media file once the page is loaded.
Elements that accept this attribute are <audio>, and <video>.
An autoplay attribute on an <audio> element. To avoid surprises, we disabled autoplay on this page. Click 'Try It live' to see it enabled.
<audio autoplay controls>
<source src="/media/epic.mp3" type="audio/mpeg">
<source src="/media/epic.wav" type="audio/wav">
</audio>
For additional details see our HTML audio autoplay Reference.
With this attribute, the audio or video file will start playing even before the entire file is loaded.
Suddenly playing an audio or video may startle users because they are not expecting it.
It is usually best to give users control over when to start.
<tagname autoplay>
These elements accept the autoplay
attribute:
Elements | Description | |
---|---|---|
<audio> | Creates an audio player -- see example above | |
<video> | Creates a video player |
An autoplay attribute on a <video> tag.
Note: we disabled autoplay on this page. Click 'Try It live' to see it enabled.
<video width="320" autoplay>
<source src="/media/movie.mp4" type="video/mp4">
<source src="/media/movie.ogg" type="video/ogg">
</video>
For additional details see our HTML video autoplay Reference.
Here is when autoplay
support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |