1

i want to get my autoplay html5 videos to work on safari too. Ive read plenty threads about that topic already but couldnt find a solution which provides functionality on both browsers. Link to my website:

            <video autoplay loop muted playsinline width="640" height="510">
        <source src="http://dl3.webmfiles.org/elephants-dream.webm" type="video/webm">
        <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
        </video>
Sphex OW
  • 21
  • 4
  • 1
    Take a look here please: https://stackoverflow.com/questions/17994666/video-auto-play-is-not-working-in-safari-and-chrome-desktop-browser [Duplicate] – Sigma Oct 02 '18 at 16:22
  • I think the answer you are looking for is here: https://stackoverflow.com/questions/17994666/video-auto-play-is-not-working-in-safari-and-chrome-desktop-browser – tomer raitz Oct 02 '18 at 16:23
  • I tried multiple possible solutions but none of them worked after all, for him it didnt work on neither chrome nor safari, but for me it works everywhere besides safari. – Sphex OW Oct 03 '18 at 09:47

1 Answers1

0

Apple has blocked autoplay on video in the latest version of Safari, which was announced at the WWDC 2018 alongside macOS Mojave. As a result, the autoplay attribute won't work on Safari.

The only way to circumvent this would be to use JavaScript to play the video. A delay of 1 second has been put in to allow time for everything to load and to improve the UX for the user.

setTimeout(function() { 
    var vid = document.getElementById("myVideo");
    vid.play(); 
}, 1000);
Bilaal Rashid
  • 828
  • 2
  • 13
  • 21