chrome html5 video stops autoplay after a second or two

自古美人都是妖i 提交于 2020-01-16 12:04:12

问题


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>

And you can check it here:

http://taslogistics.website.2018.360southclients.net:8080/

Any help would be greatly appreciated!


回答1:


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

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


来源:https://stackoverflow.com/questions/51585771/chrome-html5-video-stops-autoplay-after-a-second-or-two

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!