Mastering the Media: Complete HTML Course
Sobre a Aula

Auto-Start Videos with the video Element

When you want a video to start playing automatically as soon as the page loads, the autoplay attribute is used.

See the example:

<video width="320" height="240" autoplay>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

However, it is important to note that some Chromium-based browsers may impose restrictions on autoplay under certain circumstances.

Despite this, autoplay is generally still permitted when the video is muted.

To ensure consistent autoplay, even in browsers that may restrict it, you can add the muted and autoplay attributes.

This combination allows the video to start automatically but without sound, providing a smoother experience and avoiding potential autoplay issues.

Now, take a look at this example:

<video width="320" height="240" autoplay muted>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Entrar na conversa
Rolar para cima