How to play a video automatically in google chrome?

2

I developed a website for a company and it requested a video just below the menu, and that this video was automatically reproduced, until then nothing else I 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>

Just one thing in this code in browsers Firefox, Edge, and Opera worked well for automatic playback, however in google Chrome, which is the most used, no! So my help plea as I do to reproduce this came 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>
    
asked by anonymous 06.09.2018 / 14:03

1 answer

0

According to this article in developers.google , starting with version 53 of Chrome automatic playback is respected by the browser if the video is muted.

To do this use: autoplay muted

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

In addition, muted playback can now be started using the    play() method. Previously, play() would only start playback if   come from a user gesture, such as a click on the button. Source: developers.google

Incremental playback 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>
    
06.09.2018 / 15:40