Search code examples
htmlgoogle-chromehtml5-video

chrome html5 video stops autoplay after a second or two


I've got an autoplaying video which works well on all browsers, except Chrome - which has apparently disabled autoplay video. I've tried some work arounds, but now it just plays for 1-2 seconds and stops entirely.

Here's my code:

<video id="introduction-video" preload="auto" playsinline autoplay muted loop volume="0" poster="/images/videos/video-background.png" width="100%" height="100%">
            <source src="/images/videos/Tasman10seconds.mp4" type="video/mp4">
            <source src="/images/videos/Tasman10seconds.webm" type="video/webm">
            Sorry, your browser does not support HTML5 video.
        </video>
        <script>$(window).on('load',function(){$('#introduction-video').get(0).play();});</script>

Any help would be greatly appreciated!


Solution

  • For anyone else having this issue, this worked for me..

    $(window).bind('load',function(){
        'use strict';
        $('#introduction-video').trigger('play');
    });