问题
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