Chrome video autoplay

alib0ng0 picture alib0ng0 · May 30, 2018 · Viewed 18.4k times · Source

Following Chrome & Firefox's recent update autoplay videos are no longer supported - I've tried to add some code to play this on startup but it doesn't seem to work?

    var vid = document.getElementById("attractor"); 

    function playVid() { 
        vid.play(); 
    } 

Has anyone found a workaround to this?

We do a lot of touch-screen interactives and rely on this method for our attractor videos.

Answer

Sabba Keynejad picture Sabba Keynejad · Jul 29, 2018

autoplay will only work if you specify it as muted by default, like this.

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

Don't worry, users will be able to unmute the video as part of the html5 video element.