Reputation: 81
When loading the page (clicking on index.html), the video doesn't play. After hitting F5 a couple times it does play. Whenever I open the index.html file the video almost never plays.
The video is stuck on the first frame when loading up, like a picture. After refreshing 1/2 times it does play but NEVER on the first load.
This problem is on Google Chrome.
On firefox it works on the first load.
On Internet Explorer it also works on the first load.
<video id="vid" class="backvid" autoplay loop>
<source src="assets/vids/bg.mp4" type="video/mp4">
</video>
This is the code I have used. I have no idea how to post a jsfiddle or a snippet for this problem, since it contains a video. Maybe it is possible to force refresh the video on load, but I have no idea how to code this.
Upvotes: 3
Views: 5439
Reputation: 81
<video id="vid" class="backvid" autoplay loop>
<source src="assets/vids/bg.mp4" type="video/mp4">
</video>
<style>
.backvid{
display:none;
}
</style>
<script>
$(document).ready(function(){
$(".backvid").show();
});
</script>
For some reason if you add .show()
it will work.
You must use jQuery
in order for this solution to work.
Upvotes: 5
Reputation: 381
<script>
document.getElementById('vid').play();
</script>
Could you add that after </video>
to see if it works?
Upvotes: 2
Reputation: 21
You clear your chrome browser history and check it again. Because in my browser I face same issue and after clearing history my video
Upvotes: 0