How to play a video automatically on google Chrome?

Asked

Viewed 1,641 times

2

I developed a website for a company and this requested a video just below the menu, and that this video be played automatically, until then nothing else used the following code:

<video  preload="auto" autoplay="true" loop style="height: 700px;" >
        <!--<source src="assets/video/entrada.mp4" type="video/mp4">-->
        <source src="assets/video/enter.mp4" type="video/mp4">
        Seu navegador não suporta HTML5.
    </video>

Except that something happened in this code in the browsers Firefox, Edge, and Opera worked well the automatic playback, but in google Chrome, which is the most used, no! So my beg for help how do I play this video automatically in Chrome already tried also via iframe as in the code below:

<iframe width="1520" height="700" src="video.html" frameborder="0"  allowfullscreen ></iframe>
  • Try to put in just autoplay nay use that way autoplay="true". Do a test there to see. I’m not sure if it will work, but it’s worth the test right...

  • It didn’t work hugocsl, but thanks for the try anyway. I think a Google joke this, I’ll keep looking in case I find something that can help me put there vlw.

  • Try to muted on the video tag, sometimes without sound enabled it allows autoplay...

1 answer

0

According to that Article in google developers., from version 53 of Chrome automatic playback is respected by the browser if the video is muted.

For that use: autoplay muted

<video autoplay muted>
  <source src="video.webm" type="video/webm" />
  <source src="video.mp4" type="video/mp4" />
</video>

In addition, disabled playback can now be started using the method play(). Formerly, play() would only initiate reproduction if came from a user gesture, like a click on the button. Source: google developers.

Increased reproduction with JS:

document.getElementById('video1').play();
<video src="https://player.vimeo.com/external/247833422.hd.mp4?s=8d872a36d3dbe7f74e9613ab144d088b5bab6649&profile_id=174" id="video1" poster="" preload autoplay loop></video>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.